28018ee163ae685c1e3505bcb4b229783ff0466f
[ldk-java] / src / main / jni / bindings.c.body
1 #include <jni.h>
2 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
3 #define int64_t jlong
4 #include "org_ldk_impl_bindings.h"
5 #include <lightning.h>
6 #include <string.h>
7 #include <stdatomic.h>
8 #include <stdlib.h>
9
10 #define LIKELY(v) __builtin_expect(!!(v), 1)
11 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
12
13 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
14 #define MALLOC(a, _) malloc(a)
15 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
16 #define CHECK_ACCESS(p)
17 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
18 #define DO_ASSERT(a) (void)(a)
19 #define CHECK(a)
20
21 static jmethodID ordinal_meth = NULL;
22 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class) {
23         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
24         CHECK(ordinal_meth != NULL);
25 }
26
27 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
28 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
29 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
30 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
31
32 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
33 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
34 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
35
36 typedef jlongArray int64_tArray;
37 typedef jbyteArray int8_tArray;
38
39 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
40         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
41         char* conv_buf = MALLOC(len + 1, "str conv buf");
42         memcpy(conv_buf, chars, len);
43         conv_buf[len] = 0;
44         jstring ret = (*env)->NewStringUTF(env, conv_buf);
45         FREE(conv_buf);
46         return ret;
47 }
48 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
49         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
50         char* newchars = MALLOC(str_len + 1, "String chars");
51         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
52         memcpy(newchars, jchars, str_len);
53         newchars[str_len] = 0;
54         (*env)->ReleaseStringUTFChars(env, str, jchars);
55         LDKStr res = {
56                 .chars = newchars,
57                 .len = str_len,
58                 .chars_is_owned = true
59         };
60         return res;
61 }
62
63 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
64         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
65 }
66 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
67         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
68 }
69 #include "version.c"
70 static jclass arr_of_B_clz = NULL;
71 static jclass arr_of_J_clz = NULL;
72 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
73         arr_of_B_clz = (*env)->FindClass(env, "[B");
74         CHECK(arr_of_B_clz != NULL);
75         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
76         arr_of_J_clz = (*env)->FindClass(env, "[J");
77         CHECK(arr_of_J_clz != NULL);
78         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
79 }
80 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
81
82 static inline void* untag_ptr(uint64_t ptr) {
83         if (ptr < 4096) return (void*)ptr;
84         if (sizeof(void*) == 4) {
85                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
86                 return (void*)(uintptr_t)ptr;
87         } else {
88                 // For 64-bit systems, assume the top byte is used for tagging, then
89                 // use bit 9 ^ bit 10.
90                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
91                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
92 #ifdef LDK_DEBUG_BUILD
93                 // On debug builds we also use the 11th bit as a debug flag
94                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
95                 CHECK(tenth_bit != eleventh_bit);
96                 p ^= 1ULL << 53;
97 #endif
98                 return (void*)p;
99         }
100 }
101 static inline bool ptr_is_owned(uint64_t ptr) {
102         if(ptr < 4096) return true;
103         if (sizeof(void*) == 4) {
104                 return ptr & (1ULL << 32);
105         } else {
106                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
107                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
108 #ifdef LDK_DEBUG_BUILD
109                 // On debug builds we also use the 11th bit as a debug flag
110                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
111                 CHECK(tenth_bit != eleventh_bit);
112 #endif
113                 return (ninth_bit ^ tenth_bit) ? true : false;
114         }
115 }
116 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
117         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
118         if (sizeof(void*) == 4) {
119                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
120         } else {
121                 CHECK(sizeof(uintptr_t) == 8);
122                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
123                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
124 #ifdef LDK_DEBUG_BUILD
125                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
126                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
127                 CHECK(ninth_bit == tenth_bit);
128                 CHECK(ninth_bit == eleventh_bit);
129                 t ^= 1ULL << 53;
130 #endif
131                 CHECK(ptr_is_owned(t) == is_owned);
132                 CHECK(untag_ptr(t) == ptr);
133                 return t;
134         }
135 }
136
137 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
138         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
139         if (UNLIKELY((*env)->ExceptionCheck(env))) {
140                 (*env)->ExceptionDescribe(env);
141                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
142         }
143         switch (ord) {
144                 case 0: return LDKAccessError_UnknownChain;
145                 case 1: return LDKAccessError_UnknownTx;
146         }
147         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
148         abort(); // Unreachable, but will let the compiler know we don't return here
149 }
150 static jclass AccessError_class = NULL;
151 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
152 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
153 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
154         AccessError_class = (*env)->NewGlobalRef(env, clz);
155         CHECK(AccessError_class != NULL);
156         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
157         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
158         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
159         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
160 }
161 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
162         switch (val) {
163                 case LDKAccessError_UnknownChain:
164                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
165                 case LDKAccessError_UnknownTx:
166                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
167                 default: abort();
168         }
169 }
170
171 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
172         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
173         if (UNLIKELY((*env)->ExceptionCheck(env))) {
174                 (*env)->ExceptionDescribe(env);
175                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
176         }
177         switch (ord) {
178                 case 0: return LDKCOption_NoneZ_Some;
179                 case 1: return LDKCOption_NoneZ_None;
180         }
181         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
182         abort(); // Unreachable, but will let the compiler know we don't return here
183 }
184 static jclass COption_NoneZ_class = NULL;
185 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
186 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
187 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
188         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
189         CHECK(COption_NoneZ_class != NULL);
190         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
191         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
192         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
193         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
194 }
195 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
196         switch (val) {
197                 case LDKCOption_NoneZ_Some:
198                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
199                 case LDKCOption_NoneZ_None:
200                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
201                 default: abort();
202         }
203 }
204
205 static inline LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_from_java(JNIEnv *env, jclass clz) {
206         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
207         if (UNLIKELY((*env)->ExceptionCheck(env))) {
208                 (*env)->ExceptionDescribe(env);
209                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust threw an exception.");
210         }
211         switch (ord) {
212                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
213                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
214                 case 2: return LDKChannelMonitorUpdateStatus_PermanentFailure;
215         }
216         (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust returned an invalid value.");
217         abort(); // Unreachable, but will let the compiler know we don't return here
218 }
219 static jclass ChannelMonitorUpdateStatus_class = NULL;
220 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = NULL;
221 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = NULL;
222 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = NULL;
223 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateStatus_init (JNIEnv *env, jclass clz) {
224         ChannelMonitorUpdateStatus_class = (*env)->NewGlobalRef(env, clz);
225         CHECK(ChannelMonitorUpdateStatus_class != NULL);
226         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_Completed", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
227         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed != NULL);
228         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_InProgress", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
229         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress != NULL);
230         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
231         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure != NULL);
232 }
233 static inline jclass LDKChannelMonitorUpdateStatus_to_java(JNIEnv *env, LDKChannelMonitorUpdateStatus val) {
234         switch (val) {
235                 case LDKChannelMonitorUpdateStatus_Completed:
236                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed);
237                 case LDKChannelMonitorUpdateStatus_InProgress:
238                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress);
239                 case LDKChannelMonitorUpdateStatus_PermanentFailure:
240                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure);
241                 default: abort();
242         }
243 }
244
245 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
246         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
247         if (UNLIKELY((*env)->ExceptionCheck(env))) {
248                 (*env)->ExceptionDescribe(env);
249                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
250         }
251         switch (ord) {
252                 case 0: return LDKConfirmationTarget_Background;
253                 case 1: return LDKConfirmationTarget_Normal;
254                 case 2: return LDKConfirmationTarget_HighPriority;
255         }
256         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
257         abort(); // Unreachable, but will let the compiler know we don't return here
258 }
259 static jclass ConfirmationTarget_class = NULL;
260 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
261 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
262 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
263 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
264         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
265         CHECK(ConfirmationTarget_class != NULL);
266         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
267         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
268         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
269         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
270         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
271         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
272 }
273 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
274         switch (val) {
275                 case LDKConfirmationTarget_Background:
276                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
277                 case LDKConfirmationTarget_Normal:
278                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
279                 case LDKConfirmationTarget_HighPriority:
280                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
281                 default: abort();
282         }
283 }
284
285 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
286         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
287         if (UNLIKELY((*env)->ExceptionCheck(env))) {
288                 (*env)->ExceptionDescribe(env);
289                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
290         }
291         switch (ord) {
292                 case 0: return LDKCreationError_DescriptionTooLong;
293                 case 1: return LDKCreationError_RouteTooLong;
294                 case 2: return LDKCreationError_TimestampOutOfBounds;
295                 case 3: return LDKCreationError_InvalidAmount;
296                 case 4: return LDKCreationError_MissingRouteHints;
297         }
298         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
299         abort(); // Unreachable, but will let the compiler know we don't return here
300 }
301 static jclass CreationError_class = NULL;
302 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
303 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
304 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
305 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
306 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
307 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
308         CreationError_class = (*env)->NewGlobalRef(env, clz);
309         CHECK(CreationError_class != NULL);
310         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
311         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
312         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
313         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
314         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
315         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
316         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
317         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
318         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
319         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
320 }
321 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
322         switch (val) {
323                 case LDKCreationError_DescriptionTooLong:
324                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
325                 case LDKCreationError_RouteTooLong:
326                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
327                 case LDKCreationError_TimestampOutOfBounds:
328                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
329                 case LDKCreationError_InvalidAmount:
330                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
331                 case LDKCreationError_MissingRouteHints:
332                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
333                 default: abort();
334         }
335 }
336
337 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
338         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
339         if (UNLIKELY((*env)->ExceptionCheck(env))) {
340                 (*env)->ExceptionDescribe(env);
341                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
342         }
343         switch (ord) {
344                 case 0: return LDKCurrency_Bitcoin;
345                 case 1: return LDKCurrency_BitcoinTestnet;
346                 case 2: return LDKCurrency_Regtest;
347                 case 3: return LDKCurrency_Simnet;
348                 case 4: return LDKCurrency_Signet;
349         }
350         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
351         abort(); // Unreachable, but will let the compiler know we don't return here
352 }
353 static jclass Currency_class = NULL;
354 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
355 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
356 static jfieldID Currency_LDKCurrency_Regtest = NULL;
357 static jfieldID Currency_LDKCurrency_Simnet = NULL;
358 static jfieldID Currency_LDKCurrency_Signet = NULL;
359 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
360         Currency_class = (*env)->NewGlobalRef(env, clz);
361         CHECK(Currency_class != NULL);
362         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
363         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
364         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
365         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
366         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
367         CHECK(Currency_LDKCurrency_Regtest != NULL);
368         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
369         CHECK(Currency_LDKCurrency_Simnet != NULL);
370         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
371         CHECK(Currency_LDKCurrency_Signet != NULL);
372 }
373 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
374         switch (val) {
375                 case LDKCurrency_Bitcoin:
376                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
377                 case LDKCurrency_BitcoinTestnet:
378                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
379                 case LDKCurrency_Regtest:
380                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
381                 case LDKCurrency_Simnet:
382                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
383                 case LDKCurrency_Signet:
384                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
385                 default: abort();
386         }
387 }
388
389 static inline LDKHTLCClaim LDKHTLCClaim_from_java(JNIEnv *env, jclass clz) {
390         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
391         if (UNLIKELY((*env)->ExceptionCheck(env))) {
392                 (*env)->ExceptionDescribe(env);
393                 (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust threw an exception.");
394         }
395         switch (ord) {
396                 case 0: return LDKHTLCClaim_OfferedTimeout;
397                 case 1: return LDKHTLCClaim_OfferedPreimage;
398                 case 2: return LDKHTLCClaim_AcceptedTimeout;
399                 case 3: return LDKHTLCClaim_AcceptedPreimage;
400                 case 4: return LDKHTLCClaim_Revocation;
401         }
402         (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust returned an invalid value.");
403         abort(); // Unreachable, but will let the compiler know we don't return here
404 }
405 static jclass HTLCClaim_class = NULL;
406 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedTimeout = NULL;
407 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedPreimage = NULL;
408 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedTimeout = NULL;
409 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedPreimage = NULL;
410 static jfieldID HTLCClaim_LDKHTLCClaim_Revocation = NULL;
411 JNIEXPORT void JNICALL Java_org_ldk_enums_HTLCClaim_init (JNIEnv *env, jclass clz) {
412         HTLCClaim_class = (*env)->NewGlobalRef(env, clz);
413         CHECK(HTLCClaim_class != NULL);
414         HTLCClaim_LDKHTLCClaim_OfferedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedTimeout", "Lorg/ldk/enums/HTLCClaim;");
415         CHECK(HTLCClaim_LDKHTLCClaim_OfferedTimeout != NULL);
416         HTLCClaim_LDKHTLCClaim_OfferedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedPreimage", "Lorg/ldk/enums/HTLCClaim;");
417         CHECK(HTLCClaim_LDKHTLCClaim_OfferedPreimage != NULL);
418         HTLCClaim_LDKHTLCClaim_AcceptedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedTimeout", "Lorg/ldk/enums/HTLCClaim;");
419         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedTimeout != NULL);
420         HTLCClaim_LDKHTLCClaim_AcceptedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedPreimage", "Lorg/ldk/enums/HTLCClaim;");
421         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedPreimage != NULL);
422         HTLCClaim_LDKHTLCClaim_Revocation = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_Revocation", "Lorg/ldk/enums/HTLCClaim;");
423         CHECK(HTLCClaim_LDKHTLCClaim_Revocation != NULL);
424 }
425 static inline jclass LDKHTLCClaim_to_java(JNIEnv *env, LDKHTLCClaim val) {
426         switch (val) {
427                 case LDKHTLCClaim_OfferedTimeout:
428                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedTimeout);
429                 case LDKHTLCClaim_OfferedPreimage:
430                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedPreimage);
431                 case LDKHTLCClaim_AcceptedTimeout:
432                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedTimeout);
433                 case LDKHTLCClaim_AcceptedPreimage:
434                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedPreimage);
435                 case LDKHTLCClaim_Revocation:
436                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_Revocation);
437                 default: abort();
438         }
439 }
440
441 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
442         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
443         if (UNLIKELY((*env)->ExceptionCheck(env))) {
444                 (*env)->ExceptionDescribe(env);
445                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
446         }
447         switch (ord) {
448                 case 0: return LDKIOError_NotFound;
449                 case 1: return LDKIOError_PermissionDenied;
450                 case 2: return LDKIOError_ConnectionRefused;
451                 case 3: return LDKIOError_ConnectionReset;
452                 case 4: return LDKIOError_ConnectionAborted;
453                 case 5: return LDKIOError_NotConnected;
454                 case 6: return LDKIOError_AddrInUse;
455                 case 7: return LDKIOError_AddrNotAvailable;
456                 case 8: return LDKIOError_BrokenPipe;
457                 case 9: return LDKIOError_AlreadyExists;
458                 case 10: return LDKIOError_WouldBlock;
459                 case 11: return LDKIOError_InvalidInput;
460                 case 12: return LDKIOError_InvalidData;
461                 case 13: return LDKIOError_TimedOut;
462                 case 14: return LDKIOError_WriteZero;
463                 case 15: return LDKIOError_Interrupted;
464                 case 16: return LDKIOError_Other;
465                 case 17: return LDKIOError_UnexpectedEof;
466         }
467         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
468         abort(); // Unreachable, but will let the compiler know we don't return here
469 }
470 static jclass IOError_class = NULL;
471 static jfieldID IOError_LDKIOError_NotFound = NULL;
472 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
473 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
474 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
475 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
476 static jfieldID IOError_LDKIOError_NotConnected = NULL;
477 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
478 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
479 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
480 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
481 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
482 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
483 static jfieldID IOError_LDKIOError_InvalidData = NULL;
484 static jfieldID IOError_LDKIOError_TimedOut = NULL;
485 static jfieldID IOError_LDKIOError_WriteZero = NULL;
486 static jfieldID IOError_LDKIOError_Interrupted = NULL;
487 static jfieldID IOError_LDKIOError_Other = NULL;
488 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
489 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
490         IOError_class = (*env)->NewGlobalRef(env, clz);
491         CHECK(IOError_class != NULL);
492         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
493         CHECK(IOError_LDKIOError_NotFound != NULL);
494         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
495         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
496         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
497         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
498         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
499         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
500         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
501         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
502         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
503         CHECK(IOError_LDKIOError_NotConnected != NULL);
504         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
505         CHECK(IOError_LDKIOError_AddrInUse != NULL);
506         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
507         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
508         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
509         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
510         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
511         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
512         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
513         CHECK(IOError_LDKIOError_WouldBlock != NULL);
514         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
515         CHECK(IOError_LDKIOError_InvalidInput != NULL);
516         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
517         CHECK(IOError_LDKIOError_InvalidData != NULL);
518         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
519         CHECK(IOError_LDKIOError_TimedOut != NULL);
520         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
521         CHECK(IOError_LDKIOError_WriteZero != NULL);
522         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
523         CHECK(IOError_LDKIOError_Interrupted != NULL);
524         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
525         CHECK(IOError_LDKIOError_Other != NULL);
526         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
527         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
528 }
529 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
530         switch (val) {
531                 case LDKIOError_NotFound:
532                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
533                 case LDKIOError_PermissionDenied:
534                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
535                 case LDKIOError_ConnectionRefused:
536                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
537                 case LDKIOError_ConnectionReset:
538                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
539                 case LDKIOError_ConnectionAborted:
540                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
541                 case LDKIOError_NotConnected:
542                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
543                 case LDKIOError_AddrInUse:
544                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
545                 case LDKIOError_AddrNotAvailable:
546                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
547                 case LDKIOError_BrokenPipe:
548                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
549                 case LDKIOError_AlreadyExists:
550                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
551                 case LDKIOError_WouldBlock:
552                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
553                 case LDKIOError_InvalidInput:
554                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
555                 case LDKIOError_InvalidData:
556                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
557                 case LDKIOError_TimedOut:
558                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
559                 case LDKIOError_WriteZero:
560                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
561                 case LDKIOError_Interrupted:
562                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
563                 case LDKIOError_Other:
564                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
565                 case LDKIOError_UnexpectedEof:
566                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
567                 default: abort();
568         }
569 }
570
571 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
572         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
573         if (UNLIKELY((*env)->ExceptionCheck(env))) {
574                 (*env)->ExceptionDescribe(env);
575                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
576         }
577         switch (ord) {
578                 case 0: return LDKLevel_Gossip;
579                 case 1: return LDKLevel_Trace;
580                 case 2: return LDKLevel_Debug;
581                 case 3: return LDKLevel_Info;
582                 case 4: return LDKLevel_Warn;
583                 case 5: return LDKLevel_Error;
584         }
585         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
586         abort(); // Unreachable, but will let the compiler know we don't return here
587 }
588 static jclass Level_class = NULL;
589 static jfieldID Level_LDKLevel_Gossip = NULL;
590 static jfieldID Level_LDKLevel_Trace = NULL;
591 static jfieldID Level_LDKLevel_Debug = NULL;
592 static jfieldID Level_LDKLevel_Info = NULL;
593 static jfieldID Level_LDKLevel_Warn = NULL;
594 static jfieldID Level_LDKLevel_Error = NULL;
595 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
596         Level_class = (*env)->NewGlobalRef(env, clz);
597         CHECK(Level_class != NULL);
598         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
599         CHECK(Level_LDKLevel_Gossip != NULL);
600         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
601         CHECK(Level_LDKLevel_Trace != NULL);
602         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
603         CHECK(Level_LDKLevel_Debug != NULL);
604         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
605         CHECK(Level_LDKLevel_Info != NULL);
606         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
607         CHECK(Level_LDKLevel_Warn != NULL);
608         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
609         CHECK(Level_LDKLevel_Error != NULL);
610 }
611 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
612         switch (val) {
613                 case LDKLevel_Gossip:
614                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
615                 case LDKLevel_Trace:
616                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
617                 case LDKLevel_Debug:
618                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
619                 case LDKLevel_Info:
620                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
621                 case LDKLevel_Warn:
622                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
623                 case LDKLevel_Error:
624                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
625                 default: abort();
626         }
627 }
628
629 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
630         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
631         if (UNLIKELY((*env)->ExceptionCheck(env))) {
632                 (*env)->ExceptionDescribe(env);
633                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
634         }
635         switch (ord) {
636                 case 0: return LDKNetwork_Bitcoin;
637                 case 1: return LDKNetwork_Testnet;
638                 case 2: return LDKNetwork_Regtest;
639                 case 3: return LDKNetwork_Signet;
640         }
641         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
642         abort(); // Unreachable, but will let the compiler know we don't return here
643 }
644 static jclass Network_class = NULL;
645 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
646 static jfieldID Network_LDKNetwork_Testnet = NULL;
647 static jfieldID Network_LDKNetwork_Regtest = NULL;
648 static jfieldID Network_LDKNetwork_Signet = NULL;
649 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
650         Network_class = (*env)->NewGlobalRef(env, clz);
651         CHECK(Network_class != NULL);
652         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
653         CHECK(Network_LDKNetwork_Bitcoin != NULL);
654         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
655         CHECK(Network_LDKNetwork_Testnet != NULL);
656         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
657         CHECK(Network_LDKNetwork_Regtest != NULL);
658         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
659         CHECK(Network_LDKNetwork_Signet != NULL);
660 }
661 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
662         switch (val) {
663                 case LDKNetwork_Bitcoin:
664                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
665                 case LDKNetwork_Testnet:
666                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
667                 case LDKNetwork_Regtest:
668                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
669                 case LDKNetwork_Signet:
670                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
671                 default: abort();
672         }
673 }
674
675 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
676         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
677         if (UNLIKELY((*env)->ExceptionCheck(env))) {
678                 (*env)->ExceptionDescribe(env);
679                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
680         }
681         switch (ord) {
682                 case 0: return LDKRecipient_Node;
683                 case 1: return LDKRecipient_PhantomNode;
684         }
685         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
686         abort(); // Unreachable, but will let the compiler know we don't return here
687 }
688 static jclass Recipient_class = NULL;
689 static jfieldID Recipient_LDKRecipient_Node = NULL;
690 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
691 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
692         Recipient_class = (*env)->NewGlobalRef(env, clz);
693         CHECK(Recipient_class != NULL);
694         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
695         CHECK(Recipient_LDKRecipient_Node != NULL);
696         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
697         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
698 }
699 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
700         switch (val) {
701                 case LDKRecipient_Node:
702                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
703                 case LDKRecipient_PhantomNode:
704                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
705                 default: abort();
706         }
707 }
708
709 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
710         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
711         if (UNLIKELY((*env)->ExceptionCheck(env))) {
712                 (*env)->ExceptionDescribe(env);
713                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
714         }
715         switch (ord) {
716                 case 0: return LDKSecp256k1Error_IncorrectSignature;
717                 case 1: return LDKSecp256k1Error_InvalidMessage;
718                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
719                 case 3: return LDKSecp256k1Error_InvalidSignature;
720                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
721                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
722                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
723                 case 7: return LDKSecp256k1Error_InvalidTweak;
724                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
725                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
726                 case 10: return LDKSecp256k1Error_InvalidParityValue;
727         }
728         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
729         abort(); // Unreachable, but will let the compiler know we don't return here
730 }
731 static jclass Secp256k1Error_class = NULL;
732 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
733 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
734 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
735 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
736 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
737 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
738 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
739 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
740 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
741 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
742 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
743 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
744         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
745         CHECK(Secp256k1Error_class != NULL);
746         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
747         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
748         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
749         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
750         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
751         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
752         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
753         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
754         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
755         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
756         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
757         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
758         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
759         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
760         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
761         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
762         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
763         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
764         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
765         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
766         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
767         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
768 }
769 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
770         switch (val) {
771                 case LDKSecp256k1Error_IncorrectSignature:
772                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
773                 case LDKSecp256k1Error_InvalidMessage:
774                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
775                 case LDKSecp256k1Error_InvalidPublicKey:
776                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
777                 case LDKSecp256k1Error_InvalidSignature:
778                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
779                 case LDKSecp256k1Error_InvalidSecretKey:
780                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
781                 case LDKSecp256k1Error_InvalidSharedSecret:
782                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
783                 case LDKSecp256k1Error_InvalidRecoveryId:
784                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
785                 case LDKSecp256k1Error_InvalidTweak:
786                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
787                 case LDKSecp256k1Error_NotEnoughMemory:
788                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
789                 case LDKSecp256k1Error_InvalidPublicKeySum:
790                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
791                 case LDKSecp256k1Error_InvalidParityValue:
792                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
793                 default: abort();
794         }
795 }
796
797 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
798         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
799         if (UNLIKELY((*env)->ExceptionCheck(env))) {
800                 (*env)->ExceptionDescribe(env);
801                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
802         }
803         switch (ord) {
804                 case 0: return LDKSemanticError_NoPaymentHash;
805                 case 1: return LDKSemanticError_MultiplePaymentHashes;
806                 case 2: return LDKSemanticError_NoDescription;
807                 case 3: return LDKSemanticError_MultipleDescriptions;
808                 case 4: return LDKSemanticError_NoPaymentSecret;
809                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
810                 case 6: return LDKSemanticError_InvalidFeatures;
811                 case 7: return LDKSemanticError_InvalidRecoveryId;
812                 case 8: return LDKSemanticError_InvalidSignature;
813                 case 9: return LDKSemanticError_ImpreciseAmount;
814         }
815         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
816         abort(); // Unreachable, but will let the compiler know we don't return here
817 }
818 static jclass SemanticError_class = NULL;
819 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
820 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
821 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
822 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
823 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
824 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
825 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
826 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
827 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
828 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
829 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
830         SemanticError_class = (*env)->NewGlobalRef(env, clz);
831         CHECK(SemanticError_class != NULL);
832         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
833         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
834         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
835         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
836         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
837         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
838         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
839         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
840         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
841         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
842         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
843         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
844         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
845         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
846         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
847         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
848         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
849         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
850         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
851         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
852 }
853 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
854         switch (val) {
855                 case LDKSemanticError_NoPaymentHash:
856                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
857                 case LDKSemanticError_MultiplePaymentHashes:
858                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
859                 case LDKSemanticError_NoDescription:
860                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
861                 case LDKSemanticError_MultipleDescriptions:
862                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
863                 case LDKSemanticError_NoPaymentSecret:
864                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
865                 case LDKSemanticError_MultiplePaymentSecrets:
866                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
867                 case LDKSemanticError_InvalidFeatures:
868                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
869                 case LDKSemanticError_InvalidRecoveryId:
870                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
871                 case LDKSemanticError_InvalidSignature:
872                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
873                 case LDKSemanticError_ImpreciseAmount:
874                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
875                 default: abort();
876         }
877 }
878
879 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
880         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
881         if (UNLIKELY((*env)->ExceptionCheck(env))) {
882                 (*env)->ExceptionDescribe(env);
883                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
884         }
885         switch (ord) {
886                 case 0: return LDKSiPrefix_Milli;
887                 case 1: return LDKSiPrefix_Micro;
888                 case 2: return LDKSiPrefix_Nano;
889                 case 3: return LDKSiPrefix_Pico;
890         }
891         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
892         abort(); // Unreachable, but will let the compiler know we don't return here
893 }
894 static jclass SiPrefix_class = NULL;
895 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
896 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
897 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
898 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
899 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
900         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
901         CHECK(SiPrefix_class != NULL);
902         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
903         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
904         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
905         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
906         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
907         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
908         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
909         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
910 }
911 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
912         switch (val) {
913                 case LDKSiPrefix_Milli:
914                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
915                 case LDKSiPrefix_Micro:
916                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
917                 case LDKSiPrefix_Nano:
918                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
919                 case LDKSiPrefix_Pico:
920                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
921                 default: abort();
922         }
923 }
924
925 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
926         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
927         return ret;
928 }
929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
930         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
931         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
933         return ret_arr;
934 }
935
936 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
938         if (!ptr_is_owned(thing)) return;
939         void* thing_ptr = untag_ptr(thing);
940         CHECK_ACCESS(thing_ptr);
941         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
942         FREE(untag_ptr(thing));
943         BigEndianScalar_free(thing_conv);
944 }
945
946 static jclass LDKBech32Error_MissingSeparator_class = NULL;
947 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
948 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
949 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
950 static jclass LDKBech32Error_InvalidLength_class = NULL;
951 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
952 static jclass LDKBech32Error_InvalidChar_class = NULL;
953 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
954 static jclass LDKBech32Error_InvalidData_class = NULL;
955 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
956 static jclass LDKBech32Error_InvalidPadding_class = NULL;
957 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
958 static jclass LDKBech32Error_MixedCase_class = NULL;
959 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
961         LDKBech32Error_MissingSeparator_class =
962                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
963         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
964         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
965         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
966         LDKBech32Error_InvalidChecksum_class =
967                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
968         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
969         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
970         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
971         LDKBech32Error_InvalidLength_class =
972                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
973         CHECK(LDKBech32Error_InvalidLength_class != NULL);
974         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
975         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
976         LDKBech32Error_InvalidChar_class =
977                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
978         CHECK(LDKBech32Error_InvalidChar_class != NULL);
979         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
980         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
981         LDKBech32Error_InvalidData_class =
982                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
983         CHECK(LDKBech32Error_InvalidData_class != NULL);
984         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
985         CHECK(LDKBech32Error_InvalidData_meth != NULL);
986         LDKBech32Error_InvalidPadding_class =
987                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
988         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
989         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
990         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
991         LDKBech32Error_MixedCase_class =
992                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
993         CHECK(LDKBech32Error_MixedCase_class != NULL);
994         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
995         CHECK(LDKBech32Error_MixedCase_meth != NULL);
996 }
997 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
998         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
999         switch(obj->tag) {
1000                 case LDKBech32Error_MissingSeparator: {
1001                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1002                 }
1003                 case LDKBech32Error_InvalidChecksum: {
1004                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1005                 }
1006                 case LDKBech32Error_InvalidLength: {
1007                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1008                 }
1009                 case LDKBech32Error_InvalidChar: {
1010                         int32_t invalid_char_conv = obj->invalid_char;
1011                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1012                 }
1013                 case LDKBech32Error_InvalidData: {
1014                         int8_t invalid_data_conv = obj->invalid_data;
1015                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1016                 }
1017                 case LDKBech32Error_InvalidPadding: {
1018                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1019                 }
1020                 case LDKBech32Error_MixedCase: {
1021                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1022                 }
1023                 default: abort();
1024         }
1025 }
1026 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1027         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1028         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1029         return ret;
1030 }
1031 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) {
1032         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1033         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1036         CVec_u8Z_free(ret_var);
1037         return ret_arr;
1038 }
1039
1040 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) {
1041         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1042         int64_t ret_conv = TxOut_get_value(thing_conv);
1043         return ret_conv;
1044 }
1045
1046 static jclass LDKCOption_HTLCClaimZ_Some_class = NULL;
1047 static jmethodID LDKCOption_HTLCClaimZ_Some_meth = NULL;
1048 static jclass LDKCOption_HTLCClaimZ_None_class = NULL;
1049 static jmethodID LDKCOption_HTLCClaimZ_None_meth = NULL;
1050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCClaimZ_init (JNIEnv *env, jclass clz) {
1051         LDKCOption_HTLCClaimZ_Some_class =
1052                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$Some"));
1053         CHECK(LDKCOption_HTLCClaimZ_Some_class != NULL);
1054         LDKCOption_HTLCClaimZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_Some_class, "<init>", "(Lorg/ldk/enums/HTLCClaim;)V");
1055         CHECK(LDKCOption_HTLCClaimZ_Some_meth != NULL);
1056         LDKCOption_HTLCClaimZ_None_class =
1057                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$None"));
1058         CHECK(LDKCOption_HTLCClaimZ_None_class != NULL);
1059         LDKCOption_HTLCClaimZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_None_class, "<init>", "()V");
1060         CHECK(LDKCOption_HTLCClaimZ_None_meth != NULL);
1061 }
1062 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCClaimZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1063         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
1064         switch(obj->tag) {
1065                 case LDKCOption_HTLCClaimZ_Some: {
1066                         jclass some_conv = LDKHTLCClaim_to_java(env, obj->some);
1067                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_Some_class, LDKCOption_HTLCClaimZ_Some_meth, some_conv);
1068                 }
1069                 case LDKCOption_HTLCClaimZ_None: {
1070                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_None_class, LDKCOption_HTLCClaimZ_None_meth);
1071                 }
1072                 default: abort();
1073         }
1074 }
1075 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1076 CHECK(owner->result_ok);
1077         return *owner->contents.result;
1078 }
1079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1080         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1081         CResult_NoneNoneZ_get_ok(owner_conv);
1082 }
1083
1084 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1085 CHECK(!owner->result_ok);
1086         return *owner->contents.err;
1087 }
1088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1089         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1090         CResult_NoneNoneZ_get_err(owner_conv);
1091 }
1092
1093 static jclass LDKDecodeError_UnknownVersion_class = NULL;
1094 static jmethodID LDKDecodeError_UnknownVersion_meth = NULL;
1095 static jclass LDKDecodeError_UnknownRequiredFeature_class = NULL;
1096 static jmethodID LDKDecodeError_UnknownRequiredFeature_meth = NULL;
1097 static jclass LDKDecodeError_InvalidValue_class = NULL;
1098 static jmethodID LDKDecodeError_InvalidValue_meth = NULL;
1099 static jclass LDKDecodeError_ShortRead_class = NULL;
1100 static jmethodID LDKDecodeError_ShortRead_meth = NULL;
1101 static jclass LDKDecodeError_BadLengthDescriptor_class = NULL;
1102 static jmethodID LDKDecodeError_BadLengthDescriptor_meth = NULL;
1103 static jclass LDKDecodeError_Io_class = NULL;
1104 static jmethodID LDKDecodeError_Io_meth = NULL;
1105 static jclass LDKDecodeError_UnsupportedCompression_class = NULL;
1106 static jmethodID LDKDecodeError_UnsupportedCompression_meth = NULL;
1107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDecodeError_init (JNIEnv *env, jclass clz) {
1108         LDKDecodeError_UnknownVersion_class =
1109                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownVersion"));
1110         CHECK(LDKDecodeError_UnknownVersion_class != NULL);
1111         LDKDecodeError_UnknownVersion_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownVersion_class, "<init>", "()V");
1112         CHECK(LDKDecodeError_UnknownVersion_meth != NULL);
1113         LDKDecodeError_UnknownRequiredFeature_class =
1114                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownRequiredFeature"));
1115         CHECK(LDKDecodeError_UnknownRequiredFeature_class != NULL);
1116         LDKDecodeError_UnknownRequiredFeature_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownRequiredFeature_class, "<init>", "()V");
1117         CHECK(LDKDecodeError_UnknownRequiredFeature_meth != NULL);
1118         LDKDecodeError_InvalidValue_class =
1119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$InvalidValue"));
1120         CHECK(LDKDecodeError_InvalidValue_class != NULL);
1121         LDKDecodeError_InvalidValue_meth = (*env)->GetMethodID(env, LDKDecodeError_InvalidValue_class, "<init>", "()V");
1122         CHECK(LDKDecodeError_InvalidValue_meth != NULL);
1123         LDKDecodeError_ShortRead_class =
1124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$ShortRead"));
1125         CHECK(LDKDecodeError_ShortRead_class != NULL);
1126         LDKDecodeError_ShortRead_meth = (*env)->GetMethodID(env, LDKDecodeError_ShortRead_class, "<init>", "()V");
1127         CHECK(LDKDecodeError_ShortRead_meth != NULL);
1128         LDKDecodeError_BadLengthDescriptor_class =
1129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$BadLengthDescriptor"));
1130         CHECK(LDKDecodeError_BadLengthDescriptor_class != NULL);
1131         LDKDecodeError_BadLengthDescriptor_meth = (*env)->GetMethodID(env, LDKDecodeError_BadLengthDescriptor_class, "<init>", "()V");
1132         CHECK(LDKDecodeError_BadLengthDescriptor_meth != NULL);
1133         LDKDecodeError_Io_class =
1134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$Io"));
1135         CHECK(LDKDecodeError_Io_class != NULL);
1136         LDKDecodeError_Io_meth = (*env)->GetMethodID(env, LDKDecodeError_Io_class, "<init>", "(Lorg/ldk/enums/IOError;)V");
1137         CHECK(LDKDecodeError_Io_meth != NULL);
1138         LDKDecodeError_UnsupportedCompression_class =
1139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnsupportedCompression"));
1140         CHECK(LDKDecodeError_UnsupportedCompression_class != NULL);
1141         LDKDecodeError_UnsupportedCompression_meth = (*env)->GetMethodID(env, LDKDecodeError_UnsupportedCompression_class, "<init>", "()V");
1142         CHECK(LDKDecodeError_UnsupportedCompression_meth != NULL);
1143 }
1144 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1145         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
1146         switch(obj->tag) {
1147                 case LDKDecodeError_UnknownVersion: {
1148                         return (*env)->NewObject(env, LDKDecodeError_UnknownVersion_class, LDKDecodeError_UnknownVersion_meth);
1149                 }
1150                 case LDKDecodeError_UnknownRequiredFeature: {
1151                         return (*env)->NewObject(env, LDKDecodeError_UnknownRequiredFeature_class, LDKDecodeError_UnknownRequiredFeature_meth);
1152                 }
1153                 case LDKDecodeError_InvalidValue: {
1154                         return (*env)->NewObject(env, LDKDecodeError_InvalidValue_class, LDKDecodeError_InvalidValue_meth);
1155                 }
1156                 case LDKDecodeError_ShortRead: {
1157                         return (*env)->NewObject(env, LDKDecodeError_ShortRead_class, LDKDecodeError_ShortRead_meth);
1158                 }
1159                 case LDKDecodeError_BadLengthDescriptor: {
1160                         return (*env)->NewObject(env, LDKDecodeError_BadLengthDescriptor_class, LDKDecodeError_BadLengthDescriptor_meth);
1161                 }
1162                 case LDKDecodeError_Io: {
1163                         jclass io_conv = LDKIOError_to_java(env, obj->io);
1164                         return (*env)->NewObject(env, LDKDecodeError_Io_class, LDKDecodeError_Io_meth, io_conv);
1165                 }
1166                 case LDKDecodeError_UnsupportedCompression: {
1167                         return (*env)->NewObject(env, LDKDecodeError_UnsupportedCompression_class, LDKDecodeError_UnsupportedCompression_meth);
1168                 }
1169                 default: abort();
1170         }
1171 }
1172 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1173         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1174         ret.is_owned = false;
1175         return ret;
1176 }
1177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1178         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1179         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1180         int64_t ret_ref = 0;
1181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1182         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1183         return ret_ref;
1184 }
1185
1186 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1187 CHECK(!owner->result_ok);
1188         return DecodeError_clone(&*owner->contents.err);
1189 }
1190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1191         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1192         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1193         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1194         int64_t ret_ref = tag_ptr(ret_copy, true);
1195         return ret_ref;
1196 }
1197
1198 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1199         LDKTxCreationKeys ret = *owner->contents.result;
1200         ret.is_owned = false;
1201         return ret;
1202 }
1203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1204         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1205         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1206         int64_t ret_ref = 0;
1207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1209         return ret_ref;
1210 }
1211
1212 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1213 CHECK(!owner->result_ok);
1214         return DecodeError_clone(&*owner->contents.err);
1215 }
1216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1217         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1218         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1219         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1220         int64_t ret_ref = tag_ptr(ret_copy, true);
1221         return ret_ref;
1222 }
1223
1224 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1225         LDKChannelPublicKeys ret = *owner->contents.result;
1226         ret.is_owned = false;
1227         return ret;
1228 }
1229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1230         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1231         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1232         int64_t ret_ref = 0;
1233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1235         return ret_ref;
1236 }
1237
1238 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1239 CHECK(!owner->result_ok);
1240         return DecodeError_clone(&*owner->contents.err);
1241 }
1242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1243         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1244         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1245         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1246         int64_t ret_ref = tag_ptr(ret_copy, true);
1247         return ret_ref;
1248 }
1249
1250 static jclass LDKCOption_u32Z_Some_class = NULL;
1251 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1252 static jclass LDKCOption_u32Z_None_class = NULL;
1253 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1255         LDKCOption_u32Z_Some_class =
1256                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1257         CHECK(LDKCOption_u32Z_Some_class != NULL);
1258         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1259         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1260         LDKCOption_u32Z_None_class =
1261                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1262         CHECK(LDKCOption_u32Z_None_class != NULL);
1263         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1264         CHECK(LDKCOption_u32Z_None_meth != NULL);
1265 }
1266 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1267         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1268         switch(obj->tag) {
1269                 case LDKCOption_u32Z_Some: {
1270                         int32_t some_conv = obj->some;
1271                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1272                 }
1273                 case LDKCOption_u32Z_None: {
1274                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1275                 }
1276                 default: abort();
1277         }
1278 }
1279 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1280         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1281         ret.is_owned = false;
1282         return ret;
1283 }
1284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1285         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1286         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1287         int64_t ret_ref = 0;
1288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1290         return ret_ref;
1291 }
1292
1293 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1294 CHECK(!owner->result_ok);
1295         return DecodeError_clone(&*owner->contents.err);
1296 }
1297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1298         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1299         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1300         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1301         int64_t ret_ref = tag_ptr(ret_copy, true);
1302         return ret_ref;
1303 }
1304
1305 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1306         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1307         ret.is_owned = false;
1308         return ret;
1309 }
1310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1311         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1312         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1313         int64_t ret_ref = 0;
1314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1316         return ret_ref;
1317 }
1318
1319 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1320 CHECK(!owner->result_ok);
1321         return DecodeError_clone(&*owner->contents.err);
1322 }
1323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1324         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1325         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1326         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1327         int64_t ret_ref = tag_ptr(ret_copy, true);
1328         return ret_ref;
1329 }
1330
1331 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1332         LDKChannelTransactionParameters ret = *owner->contents.result;
1333         ret.is_owned = false;
1334         return ret;
1335 }
1336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1337         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1338         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1339         int64_t ret_ref = 0;
1340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1342         return ret_ref;
1343 }
1344
1345 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1346 CHECK(!owner->result_ok);
1347         return DecodeError_clone(&*owner->contents.err);
1348 }
1349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1350         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1351         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1352         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1353         int64_t ret_ref = tag_ptr(ret_copy, true);
1354         return ret_ref;
1355 }
1356
1357 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1358         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1359         ret.is_owned = false;
1360         return ret;
1361 }
1362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1363         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1364         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1365         int64_t ret_ref = 0;
1366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1368         return ret_ref;
1369 }
1370
1371 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1372 CHECK(!owner->result_ok);
1373         return DecodeError_clone(&*owner->contents.err);
1374 }
1375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1376         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1377         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1378         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1379         int64_t ret_ref = tag_ptr(ret_copy, true);
1380         return ret_ref;
1381 }
1382
1383 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1384         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1385         ret.is_owned = false;
1386         return ret;
1387 }
1388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1389         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1390         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1391         int64_t ret_ref = 0;
1392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1394         return ret_ref;
1395 }
1396
1397 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1398 CHECK(!owner->result_ok);
1399         return DecodeError_clone(&*owner->contents.err);
1400 }
1401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1402         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1403         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1404         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1405         int64_t ret_ref = tag_ptr(ret_copy, true);
1406         return ret_ref;
1407 }
1408
1409 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1410         LDKTrustedClosingTransaction ret = *owner->contents.result;
1411         ret.is_owned = false;
1412         return ret;
1413 }
1414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1415         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1416         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1417         int64_t ret_ref = 0;
1418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1420         return ret_ref;
1421 }
1422
1423 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1424 CHECK(!owner->result_ok);
1425         return *owner->contents.err;
1426 }
1427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1428         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1429         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1430 }
1431
1432 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1433         LDKCommitmentTransaction ret = *owner->contents.result;
1434         ret.is_owned = false;
1435         return ret;
1436 }
1437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1438         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1439         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1440         int64_t ret_ref = 0;
1441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1443         return ret_ref;
1444 }
1445
1446 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1447 CHECK(!owner->result_ok);
1448         return DecodeError_clone(&*owner->contents.err);
1449 }
1450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1451         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1452         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1453         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1454         int64_t ret_ref = tag_ptr(ret_copy, true);
1455         return ret_ref;
1456 }
1457
1458 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1459         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1460         ret.is_owned = false;
1461         return ret;
1462 }
1463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1464         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1465         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1466         int64_t ret_ref = 0;
1467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1468         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1469         return ret_ref;
1470 }
1471
1472 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1473 CHECK(!owner->result_ok);
1474         return *owner->contents.err;
1475 }
1476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1477         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1478         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1479 }
1480
1481 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1482 CHECK(owner->result_ok);
1483         return *owner->contents.result;
1484 }
1485 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1486         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1487         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1488         jobjectArray ret_arr = NULL;
1489         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1490         ;
1491         for (size_t i = 0; i < ret_var.datalen; i++) {
1492                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1493                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1494                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1495         }
1496         
1497         return ret_arr;
1498 }
1499
1500 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1501 CHECK(!owner->result_ok);
1502         return *owner->contents.err;
1503 }
1504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1505         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1506         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1507 }
1508
1509 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1510         LDKShutdownScript ret = *owner->contents.result;
1511         ret.is_owned = false;
1512         return ret;
1513 }
1514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1515         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1516         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1517         int64_t ret_ref = 0;
1518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1519         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1520         return ret_ref;
1521 }
1522
1523 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1524 CHECK(!owner->result_ok);
1525         return DecodeError_clone(&*owner->contents.err);
1526 }
1527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1528         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1529         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1530         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1531         int64_t ret_ref = tag_ptr(ret_copy, true);
1532         return ret_ref;
1533 }
1534
1535 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1536         LDKShutdownScript ret = *owner->contents.result;
1537         ret.is_owned = false;
1538         return ret;
1539 }
1540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1541         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1542         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1543         int64_t ret_ref = 0;
1544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1545         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1546         return ret_ref;
1547 }
1548
1549 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1550         LDKInvalidShutdownScript ret = *owner->contents.err;
1551         ret.is_owned = false;
1552         return ret;
1553 }
1554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1555         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1556         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1557         int64_t ret_ref = 0;
1558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1560         return ret_ref;
1561 }
1562
1563 static inline struct LDKBlindedPath CResult_BlindedPathNoneZ_get_ok(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
1564         LDKBlindedPath ret = *owner->contents.result;
1565         ret.is_owned = false;
1566         return ret;
1567 }
1568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1569         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
1570         LDKBlindedPath ret_var = CResult_BlindedPathNoneZ_get_ok(owner_conv);
1571         int64_t ret_ref = 0;
1572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1573         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1574         return ret_ref;
1575 }
1576
1577 static inline void CResult_BlindedPathNoneZ_get_err(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
1578 CHECK(!owner->result_ok);
1579         return *owner->contents.err;
1580 }
1581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1582         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
1583         CResult_BlindedPathNoneZ_get_err(owner_conv);
1584 }
1585
1586 static inline struct LDKBlindedPath CResult_BlindedPathDecodeErrorZ_get_ok(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
1587         LDKBlindedPath ret = *owner->contents.result;
1588         ret.is_owned = false;
1589         return ret;
1590 }
1591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1592         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
1593         LDKBlindedPath ret_var = CResult_BlindedPathDecodeErrorZ_get_ok(owner_conv);
1594         int64_t ret_ref = 0;
1595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1596         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1597         return ret_ref;
1598 }
1599
1600 static inline struct LDKDecodeError CResult_BlindedPathDecodeErrorZ_get_err(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
1601 CHECK(!owner->result_ok);
1602         return DecodeError_clone(&*owner->contents.err);
1603 }
1604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1605         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
1606         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1607         *ret_copy = CResult_BlindedPathDecodeErrorZ_get_err(owner_conv);
1608         int64_t ret_ref = tag_ptr(ret_copy, true);
1609         return ret_ref;
1610 }
1611
1612 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1613         LDKBlindedHop ret = *owner->contents.result;
1614         ret.is_owned = false;
1615         return ret;
1616 }
1617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1618         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1619         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
1620         int64_t ret_ref = 0;
1621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1622         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1623         return ret_ref;
1624 }
1625
1626 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1627 CHECK(!owner->result_ok);
1628         return DecodeError_clone(&*owner->contents.err);
1629 }
1630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1631         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1632         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1633         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
1634         int64_t ret_ref = tag_ptr(ret_copy, true);
1635         return ret_ref;
1636 }
1637
1638 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1639         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1640         for (size_t i = 0; i < ret.datalen; i++) {
1641                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1642         }
1643         return ret;
1644 }
1645 typedef struct LDKScore_JCalls {
1646         atomic_size_t refcnt;
1647         JavaVM *vm;
1648         jweak o;
1649         jmethodID channel_penalty_msat_meth;
1650         jmethodID payment_path_failed_meth;
1651         jmethodID payment_path_successful_meth;
1652         jmethodID probe_failed_meth;
1653         jmethodID probe_successful_meth;
1654         jmethodID write_meth;
1655 } LDKScore_JCalls;
1656 static void LDKScore_JCalls_free(void* this_arg) {
1657         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1658         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1659                 JNIEnv *env;
1660                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1661                 if (get_jenv_res == JNI_EDETACHED) {
1662                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1663                 } else {
1664                         DO_ASSERT(get_jenv_res == JNI_OK);
1665                 }
1666                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1667                 if (get_jenv_res == JNI_EDETACHED) {
1668                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1669                 }
1670                 FREE(j_calls);
1671         }
1672 }
1673 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
1674         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1675         JNIEnv *env;
1676         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1677         if (get_jenv_res == JNI_EDETACHED) {
1678                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1679         } else {
1680                 DO_ASSERT(get_jenv_res == JNI_OK);
1681         }
1682         int64_t short_channel_id_conv = short_channel_id;
1683         LDKNodeId source_var = *source;
1684         int64_t source_ref = 0;
1685         source_var = NodeId_clone(&source_var);
1686         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
1687         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
1688         LDKNodeId target_var = *target;
1689         int64_t target_ref = 0;
1690         target_var = NodeId_clone(&target_var);
1691         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
1692         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
1693         LDKChannelUsage usage_var = usage;
1694         int64_t usage_ref = 0;
1695         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
1696         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
1697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1698         CHECK(obj != NULL);
1699         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
1700         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1701                 (*env)->ExceptionDescribe(env);
1702                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
1703         }
1704         if (get_jenv_res == JNI_EDETACHED) {
1705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1706         }
1707         return ret;
1708 }
1709 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1710         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1711         JNIEnv *env;
1712         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1713         if (get_jenv_res == JNI_EDETACHED) {
1714                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1715         } else {
1716                 DO_ASSERT(get_jenv_res == JNI_OK);
1717         }
1718         LDKCVec_RouteHopZ path_var = path;
1719         int64_tArray path_arr = NULL;
1720         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1721         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1722         for (size_t k = 0; k < path_var.datalen; k++) {
1723                 LDKRouteHop path_conv_10_var = path_var.data[k];
1724                 int64_t path_conv_10_ref = 0;
1725                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1726                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1727                 path_arr_ptr[k] = path_conv_10_ref;
1728         }
1729         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1730         FREE(path_var.data);
1731         int64_t short_channel_id_conv = short_channel_id;
1732         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1733         CHECK(obj != NULL);
1734         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
1735         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1736                 (*env)->ExceptionDescribe(env);
1737                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
1738         }
1739         if (get_jenv_res == JNI_EDETACHED) {
1740                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1741         }
1742 }
1743 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1744         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1745         JNIEnv *env;
1746         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1747         if (get_jenv_res == JNI_EDETACHED) {
1748                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1749         } else {
1750                 DO_ASSERT(get_jenv_res == JNI_OK);
1751         }
1752         LDKCVec_RouteHopZ path_var = path;
1753         int64_tArray path_arr = NULL;
1754         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1755         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1756         for (size_t k = 0; k < path_var.datalen; k++) {
1757                 LDKRouteHop path_conv_10_var = path_var.data[k];
1758                 int64_t path_conv_10_ref = 0;
1759                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1760                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1761                 path_arr_ptr[k] = path_conv_10_ref;
1762         }
1763         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1764         FREE(path_var.data);
1765         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1766         CHECK(obj != NULL);
1767         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
1768         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1769                 (*env)->ExceptionDescribe(env);
1770                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
1771         }
1772         if (get_jenv_res == JNI_EDETACHED) {
1773                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1774         }
1775 }
1776 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1777         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1778         JNIEnv *env;
1779         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1780         if (get_jenv_res == JNI_EDETACHED) {
1781                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1782         } else {
1783                 DO_ASSERT(get_jenv_res == JNI_OK);
1784         }
1785         LDKCVec_RouteHopZ path_var = path;
1786         int64_tArray path_arr = NULL;
1787         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1788         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1789         for (size_t k = 0; k < path_var.datalen; k++) {
1790                 LDKRouteHop path_conv_10_var = path_var.data[k];
1791                 int64_t path_conv_10_ref = 0;
1792                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1793                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1794                 path_arr_ptr[k] = path_conv_10_ref;
1795         }
1796         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1797         FREE(path_var.data);
1798         int64_t short_channel_id_conv = short_channel_id;
1799         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1800         CHECK(obj != NULL);
1801         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
1802         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1803                 (*env)->ExceptionDescribe(env);
1804                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
1805         }
1806         if (get_jenv_res == JNI_EDETACHED) {
1807                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1808         }
1809 }
1810 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1811         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1812         JNIEnv *env;
1813         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1814         if (get_jenv_res == JNI_EDETACHED) {
1815                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1816         } else {
1817                 DO_ASSERT(get_jenv_res == JNI_OK);
1818         }
1819         LDKCVec_RouteHopZ path_var = path;
1820         int64_tArray path_arr = NULL;
1821         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1822         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1823         for (size_t k = 0; k < path_var.datalen; k++) {
1824                 LDKRouteHop path_conv_10_var = path_var.data[k];
1825                 int64_t path_conv_10_ref = 0;
1826                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1827                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1828                 path_arr_ptr[k] = path_conv_10_ref;
1829         }
1830         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1831         FREE(path_var.data);
1832         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1833         CHECK(obj != NULL);
1834         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
1835         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1836                 (*env)->ExceptionDescribe(env);
1837                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
1838         }
1839         if (get_jenv_res == JNI_EDETACHED) {
1840                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1841         }
1842 }
1843 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
1844         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1845         JNIEnv *env;
1846         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1847         if (get_jenv_res == JNI_EDETACHED) {
1848                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1849         } else {
1850                 DO_ASSERT(get_jenv_res == JNI_OK);
1851         }
1852         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1853         CHECK(obj != NULL);
1854         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
1855         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1856                 (*env)->ExceptionDescribe(env);
1857                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
1858         }
1859         LDKCVec_u8Z ret_ref;
1860         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
1861         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1862         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
1863         if (get_jenv_res == JNI_EDETACHED) {
1864                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1865         }
1866         return ret_ref;
1867 }
1868 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
1869         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
1870         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1871 }
1872 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
1873         jclass c = (*env)->GetObjectClass(env, o);
1874         CHECK(c != NULL);
1875         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
1876         atomic_init(&calls->refcnt, 1);
1877         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1878         calls->o = (*env)->NewWeakGlobalRef(env, o);
1879         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
1880         CHECK(calls->channel_penalty_msat_meth != NULL);
1881         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
1882         CHECK(calls->payment_path_failed_meth != NULL);
1883         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
1884         CHECK(calls->payment_path_successful_meth != NULL);
1885         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
1886         CHECK(calls->probe_failed_meth != NULL);
1887         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
1888         CHECK(calls->probe_successful_meth != NULL);
1889         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1890         CHECK(calls->write_meth != NULL);
1891
1892         LDKScore ret = {
1893                 .this_arg = (void*) calls,
1894                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
1895                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
1896                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
1897                 .probe_failed = probe_failed_LDKScore_jcall,
1898                 .probe_successful = probe_successful_LDKScore_jcall,
1899                 .write = write_LDKScore_jcall,
1900                 .free = LDKScore_JCalls_free,
1901         };
1902         return ret;
1903 }
1904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
1905         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
1906         *res_ptr = LDKScore_init(env, clz, o);
1907         return tag_ptr(res_ptr, true);
1908 }
1909 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) {
1910         void* this_arg_ptr = untag_ptr(this_arg);
1911         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1912         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1913         LDKNodeId source_conv;
1914         source_conv.inner = untag_ptr(source);
1915         source_conv.is_owned = ptr_is_owned(source);
1916         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
1917         source_conv.is_owned = false;
1918         LDKNodeId target_conv;
1919         target_conv.inner = untag_ptr(target);
1920         target_conv.is_owned = ptr_is_owned(target);
1921         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
1922         target_conv.is_owned = false;
1923         LDKChannelUsage usage_conv;
1924         usage_conv.inner = untag_ptr(usage);
1925         usage_conv.is_owned = ptr_is_owned(usage);
1926         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
1927         usage_conv = ChannelUsage_clone(&usage_conv);
1928         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
1929         return ret_conv;
1930 }
1931
1932 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) {
1933         void* this_arg_ptr = untag_ptr(this_arg);
1934         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1935         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1936         LDKCVec_RouteHopZ path_constr;
1937         path_constr.datalen = (*env)->GetArrayLength(env, path);
1938         if (path_constr.datalen > 0)
1939                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1940         else
1941                 path_constr.data = NULL;
1942         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1943         for (size_t k = 0; k < path_constr.datalen; k++) {
1944                 int64_t path_conv_10 = path_vals[k];
1945                 LDKRouteHop path_conv_10_conv;
1946                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1947                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1948                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1949                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1950                 path_constr.data[k] = path_conv_10_conv;
1951         }
1952         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
1953         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
1954 }
1955
1956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
1957         void* this_arg_ptr = untag_ptr(this_arg);
1958         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1959         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1960         LDKCVec_RouteHopZ path_constr;
1961         path_constr.datalen = (*env)->GetArrayLength(env, path);
1962         if (path_constr.datalen > 0)
1963                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1964         else
1965                 path_constr.data = NULL;
1966         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1967         for (size_t k = 0; k < path_constr.datalen; k++) {
1968                 int64_t path_conv_10 = path_vals[k];
1969                 LDKRouteHop path_conv_10_conv;
1970                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1971                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1972                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1973                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1974                 path_constr.data[k] = path_conv_10_conv;
1975         }
1976         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
1977         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
1978 }
1979
1980 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) {
1981         void* this_arg_ptr = untag_ptr(this_arg);
1982         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1983         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1984         LDKCVec_RouteHopZ path_constr;
1985         path_constr.datalen = (*env)->GetArrayLength(env, path);
1986         if (path_constr.datalen > 0)
1987                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1988         else
1989                 path_constr.data = NULL;
1990         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1991         for (size_t k = 0; k < path_constr.datalen; k++) {
1992                 int64_t path_conv_10 = path_vals[k];
1993                 LDKRouteHop path_conv_10_conv;
1994                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1995                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1996                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1997                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1998                 path_constr.data[k] = path_conv_10_conv;
1999         }
2000         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2001         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2002 }
2003
2004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2005         void* this_arg_ptr = untag_ptr(this_arg);
2006         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2007         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2008         LDKCVec_RouteHopZ path_constr;
2009         path_constr.datalen = (*env)->GetArrayLength(env, path);
2010         if (path_constr.datalen > 0)
2011                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2012         else
2013                 path_constr.data = NULL;
2014         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2015         for (size_t k = 0; k < path_constr.datalen; k++) {
2016                 int64_t path_conv_10 = path_vals[k];
2017                 LDKRouteHop path_conv_10_conv;
2018                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2019                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2020                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2021                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2022                 path_constr.data[k] = path_conv_10_conv;
2023         }
2024         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2025         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
2026 }
2027
2028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2029         void* this_arg_ptr = untag_ptr(this_arg);
2030         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2031         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2032         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2033         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2034         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2035         CVec_u8Z_free(ret_var);
2036         return ret_arr;
2037 }
2038
2039 typedef struct LDKLockableScore_JCalls {
2040         atomic_size_t refcnt;
2041         JavaVM *vm;
2042         jweak o;
2043         jmethodID lock_meth;
2044 } LDKLockableScore_JCalls;
2045 static void LDKLockableScore_JCalls_free(void* this_arg) {
2046         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2047         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2048                 JNIEnv *env;
2049                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2050                 if (get_jenv_res == JNI_EDETACHED) {
2051                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2052                 } else {
2053                         DO_ASSERT(get_jenv_res == JNI_OK);
2054                 }
2055                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2056                 if (get_jenv_res == JNI_EDETACHED) {
2057                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2058                 }
2059                 FREE(j_calls);
2060         }
2061 }
2062 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2063         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2064         JNIEnv *env;
2065         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2066         if (get_jenv_res == JNI_EDETACHED) {
2067                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2068         } else {
2069                 DO_ASSERT(get_jenv_res == JNI_OK);
2070         }
2071         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2072         CHECK(obj != NULL);
2073         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2074         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2075                 (*env)->ExceptionDescribe(env);
2076                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2077         }
2078         void* ret_ptr = untag_ptr(ret);
2079         CHECK_ACCESS(ret_ptr);
2080         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2081         if (ret_conv.free == LDKScore_JCalls_free) {
2082                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2083                 LDKScore_JCalls_cloned(&ret_conv);
2084         }// WARNING: we may need a move here but no clone is available for LDKScore
2085         
2086         if (get_jenv_res == JNI_EDETACHED) {
2087                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2088         }
2089         return ret_conv;
2090 }
2091 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2092         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2093         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2094 }
2095 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2096         jclass c = (*env)->GetObjectClass(env, o);
2097         CHECK(c != NULL);
2098         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2099         atomic_init(&calls->refcnt, 1);
2100         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2101         calls->o = (*env)->NewWeakGlobalRef(env, o);
2102         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2103         CHECK(calls->lock_meth != NULL);
2104
2105         LDKLockableScore ret = {
2106                 .this_arg = (void*) calls,
2107                 .lock = lock_LDKLockableScore_jcall,
2108                 .free = LDKLockableScore_JCalls_free,
2109         };
2110         return ret;
2111 }
2112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2113         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2114         *res_ptr = LDKLockableScore_init(env, clz, o);
2115         return tag_ptr(res_ptr, true);
2116 }
2117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2118         void* this_arg_ptr = untag_ptr(this_arg);
2119         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2120         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2121         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2122         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2123         return tag_ptr(ret_ret, true);
2124 }
2125
2126 typedef struct LDKWriteableScore_JCalls {
2127         atomic_size_t refcnt;
2128         JavaVM *vm;
2129         jweak o;
2130         LDKLockableScore_JCalls* LockableScore;
2131         jmethodID write_meth;
2132 } LDKWriteableScore_JCalls;
2133 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2134         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2135         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2136                 JNIEnv *env;
2137                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2138                 if (get_jenv_res == JNI_EDETACHED) {
2139                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2140                 } else {
2141                         DO_ASSERT(get_jenv_res == JNI_OK);
2142                 }
2143                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2144                 if (get_jenv_res == JNI_EDETACHED) {
2145                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2146                 }
2147                 FREE(j_calls);
2148         }
2149 }
2150 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2151         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2152         JNIEnv *env;
2153         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2154         if (get_jenv_res == JNI_EDETACHED) {
2155                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2156         } else {
2157                 DO_ASSERT(get_jenv_res == JNI_OK);
2158         }
2159         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2160         CHECK(obj != NULL);
2161         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2162         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2163                 (*env)->ExceptionDescribe(env);
2164                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2165         }
2166         LDKCVec_u8Z ret_ref;
2167         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2168         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2169         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2170         if (get_jenv_res == JNI_EDETACHED) {
2171                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2172         }
2173         return ret_ref;
2174 }
2175 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2176         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2177         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2178         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2179 }
2180 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2181         jclass c = (*env)->GetObjectClass(env, o);
2182         CHECK(c != NULL);
2183         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2184         atomic_init(&calls->refcnt, 1);
2185         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2186         calls->o = (*env)->NewWeakGlobalRef(env, o);
2187         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2188         CHECK(calls->write_meth != NULL);
2189
2190         LDKWriteableScore ret = {
2191                 .this_arg = (void*) calls,
2192                 .write = write_LDKWriteableScore_jcall,
2193                 .free = LDKWriteableScore_JCalls_free,
2194                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2195         };
2196         calls->LockableScore = ret.LockableScore.this_arg;
2197         return ret;
2198 }
2199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2200         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2201         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2202         return tag_ptr(res_ptr, true);
2203 }
2204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2205         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2206         return tag_ptr(&inp->LockableScore, false);
2207 }
2208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2209         void* this_arg_ptr = untag_ptr(this_arg);
2210         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2211         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2212         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2213         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2214         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2215         CVec_u8Z_free(ret_var);
2216         return ret_arr;
2217 }
2218
2219 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2220 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2221 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2222 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2224         LDKCOption_WriteableScoreZ_Some_class =
2225                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2226         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2227         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2228         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2229         LDKCOption_WriteableScoreZ_None_class =
2230                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2231         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2232         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2233         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2234 }
2235 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2236         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2237         switch(obj->tag) {
2238                 case LDKCOption_WriteableScoreZ_Some: {
2239                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2240                         *some_ret = obj->some;
2241                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2242                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2243                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2244                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2245                         }
2246                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2247                 }
2248                 case LDKCOption_WriteableScoreZ_None: {
2249                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2250                 }
2251                 default: abort();
2252         }
2253 }
2254 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2255 CHECK(owner->result_ok);
2256         return *owner->contents.result;
2257 }
2258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2259         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2260         CResult_NoneErrorZ_get_ok(owner_conv);
2261 }
2262
2263 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2264 CHECK(!owner->result_ok);
2265         return *owner->contents.err;
2266 }
2267 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2268         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2269         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2270         return ret_conv;
2271 }
2272
2273 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2274         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2275         for (size_t i = 0; i < ret.datalen; i++) {
2276                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2277         }
2278         return ret;
2279 }
2280 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2281         LDKRoute ret = *owner->contents.result;
2282         ret.is_owned = false;
2283         return ret;
2284 }
2285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2286         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2287         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2288         int64_t ret_ref = 0;
2289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2291         return ret_ref;
2292 }
2293
2294 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2295         LDKLightningError ret = *owner->contents.err;
2296         ret.is_owned = false;
2297         return ret;
2298 }
2299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2300         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2301         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2302         int64_t ret_ref = 0;
2303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2305         return ret_ref;
2306 }
2307
2308 static jclass LDKCOption_u64Z_Some_class = NULL;
2309 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2310 static jclass LDKCOption_u64Z_None_class = NULL;
2311 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2313         LDKCOption_u64Z_Some_class =
2314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
2315         CHECK(LDKCOption_u64Z_Some_class != NULL);
2316         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2317         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2318         LDKCOption_u64Z_None_class =
2319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
2320         CHECK(LDKCOption_u64Z_None_class != NULL);
2321         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2322         CHECK(LDKCOption_u64Z_None_meth != NULL);
2323 }
2324 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2325         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
2326         switch(obj->tag) {
2327                 case LDKCOption_u64Z_Some: {
2328                         int64_t some_conv = obj->some;
2329                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
2330                 }
2331                 case LDKCOption_u64Z_None: {
2332                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2333                 }
2334                 default: abort();
2335         }
2336 }
2337 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2338         LDKInFlightHtlcs ret = *owner->contents.result;
2339         ret.is_owned = false;
2340         return ret;
2341 }
2342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2343         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2344         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
2345         int64_t ret_ref = 0;
2346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2348         return ret_ref;
2349 }
2350
2351 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2352 CHECK(!owner->result_ok);
2353         return DecodeError_clone(&*owner->contents.err);
2354 }
2355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2356         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2357         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2358         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
2359         int64_t ret_ref = tag_ptr(ret_copy, true);
2360         return ret_ref;
2361 }
2362
2363 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2364         LDKRouteHop ret = *owner->contents.result;
2365         ret.is_owned = false;
2366         return ret;
2367 }
2368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2369         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2370         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2371         int64_t ret_ref = 0;
2372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2374         return ret_ref;
2375 }
2376
2377 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2378 CHECK(!owner->result_ok);
2379         return DecodeError_clone(&*owner->contents.err);
2380 }
2381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2382         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2383         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2384         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2385         int64_t ret_ref = tag_ptr(ret_copy, true);
2386         return ret_ref;
2387 }
2388
2389 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2390         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2391         for (size_t i = 0; i < ret.datalen; i++) {
2392                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2393         }
2394         return ret;
2395 }
2396 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2397         LDKRoute ret = *owner->contents.result;
2398         ret.is_owned = false;
2399         return ret;
2400 }
2401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2402         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2403         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2404         int64_t ret_ref = 0;
2405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2407         return ret_ref;
2408 }
2409
2410 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2411 CHECK(!owner->result_ok);
2412         return DecodeError_clone(&*owner->contents.err);
2413 }
2414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2415         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2416         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2417         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2418         int64_t ret_ref = tag_ptr(ret_copy, true);
2419         return ret_ref;
2420 }
2421
2422 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2423         LDKRouteParameters ret = *owner->contents.result;
2424         ret.is_owned = false;
2425         return ret;
2426 }
2427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2428         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2429         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2430         int64_t ret_ref = 0;
2431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2432         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2433         return ret_ref;
2434 }
2435
2436 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2437 CHECK(!owner->result_ok);
2438         return DecodeError_clone(&*owner->contents.err);
2439 }
2440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2441         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2442         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2443         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2444         int64_t ret_ref = tag_ptr(ret_copy, true);
2445         return ret_ref;
2446 }
2447
2448 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2449         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2450         for (size_t i = 0; i < ret.datalen; i++) {
2451                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2452         }
2453         return ret;
2454 }
2455 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2456         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2457         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2458         return ret;
2459 }
2460 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2461         LDKPaymentParameters ret = *owner->contents.result;
2462         ret.is_owned = false;
2463         return ret;
2464 }
2465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2466         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2467         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2468         int64_t ret_ref = 0;
2469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2471         return ret_ref;
2472 }
2473
2474 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2475 CHECK(!owner->result_ok);
2476         return DecodeError_clone(&*owner->contents.err);
2477 }
2478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2479         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2480         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2481         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2482         int64_t ret_ref = tag_ptr(ret_copy, true);
2483         return ret_ref;
2484 }
2485
2486 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2487         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2488         for (size_t i = 0; i < ret.datalen; i++) {
2489                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2490         }
2491         return ret;
2492 }
2493 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2494         LDKRouteHint ret = *owner->contents.result;
2495         ret.is_owned = false;
2496         return ret;
2497 }
2498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2499         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2500         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2501         int64_t ret_ref = 0;
2502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2504         return ret_ref;
2505 }
2506
2507 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2508 CHECK(!owner->result_ok);
2509         return DecodeError_clone(&*owner->contents.err);
2510 }
2511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2512         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2513         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2514         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2515         int64_t ret_ref = tag_ptr(ret_copy, true);
2516         return ret_ref;
2517 }
2518
2519 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2520         LDKRouteHintHop ret = *owner->contents.result;
2521         ret.is_owned = false;
2522         return ret;
2523 }
2524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2525         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2526         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2527         int64_t ret_ref = 0;
2528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2530         return ret_ref;
2531 }
2532
2533 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2534 CHECK(!owner->result_ok);
2535         return DecodeError_clone(&*owner->contents.err);
2536 }
2537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2538         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2539         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2540         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2541         int64_t ret_ref = tag_ptr(ret_copy, true);
2542         return ret_ref;
2543 }
2544
2545 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2546 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2547 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2548 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2550         LDKPaymentPurpose_InvoicePayment_class =
2551                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2552         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2553         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2554         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2555         LDKPaymentPurpose_SpontaneousPayment_class =
2556                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2557         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2558         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2559         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2560 }
2561 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2562         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
2563         switch(obj->tag) {
2564                 case LDKPaymentPurpose_InvoicePayment: {
2565                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2566                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2567                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2568                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2569                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2570                 }
2571                 case LDKPaymentPurpose_SpontaneousPayment: {
2572                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2573                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2574                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2575                 }
2576                 default: abort();
2577         }
2578 }
2579 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2580 CHECK(owner->result_ok);
2581         return PaymentPurpose_clone(&*owner->contents.result);
2582 }
2583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2584         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2585         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
2586         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
2587         int64_t ret_ref = tag_ptr(ret_copy, true);
2588         return ret_ref;
2589 }
2590
2591 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2592 CHECK(!owner->result_ok);
2593         return DecodeError_clone(&*owner->contents.err);
2594 }
2595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2596         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2597         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2598         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
2599         int64_t ret_ref = tag_ptr(ret_copy, true);
2600         return ret_ref;
2601 }
2602
2603 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2604 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2605 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2606 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2607 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2608 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2609 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2610 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2611 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2612 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2613 static jclass LDKClosureReason_ProcessingError_class = NULL;
2614 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2615 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2616 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2617 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2618 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2620         LDKClosureReason_CounterpartyForceClosed_class =
2621                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2622         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2623         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2624         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2625         LDKClosureReason_HolderForceClosed_class =
2626                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2627         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2628         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2629         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2630         LDKClosureReason_CooperativeClosure_class =
2631                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2632         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2633         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2634         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2635         LDKClosureReason_CommitmentTxConfirmed_class =
2636                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2637         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2638         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2639         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2640         LDKClosureReason_FundingTimedOut_class =
2641                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2642         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2643         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2644         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2645         LDKClosureReason_ProcessingError_class =
2646                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2647         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2648         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2649         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2650         LDKClosureReason_DisconnectedPeer_class =
2651                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2652         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2653         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2654         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2655         LDKClosureReason_OutdatedChannelManager_class =
2656                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2657         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2658         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2659         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2660 }
2661 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2662         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
2663         switch(obj->tag) {
2664                 case LDKClosureReason_CounterpartyForceClosed: {
2665                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2666                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2667                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2668                 }
2669                 case LDKClosureReason_HolderForceClosed: {
2670                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2671                 }
2672                 case LDKClosureReason_CooperativeClosure: {
2673                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2674                 }
2675                 case LDKClosureReason_CommitmentTxConfirmed: {
2676                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2677                 }
2678                 case LDKClosureReason_FundingTimedOut: {
2679                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2680                 }
2681                 case LDKClosureReason_ProcessingError: {
2682                         LDKStr err_str = obj->processing_error.err;
2683                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2684                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2685                 }
2686                 case LDKClosureReason_DisconnectedPeer: {
2687                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2688                 }
2689                 case LDKClosureReason_OutdatedChannelManager: {
2690                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2691                 }
2692                 default: abort();
2693         }
2694 }
2695 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2696 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2697 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2698 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2700         LDKCOption_ClosureReasonZ_Some_class =
2701                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2702         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2703         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2704         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2705         LDKCOption_ClosureReasonZ_None_class =
2706                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2707         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2708         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2709         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2710 }
2711 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2712         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
2713         switch(obj->tag) {
2714                 case LDKCOption_ClosureReasonZ_Some: {
2715                         int64_t some_ref = tag_ptr(&obj->some, false);
2716                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2717                 }
2718                 case LDKCOption_ClosureReasonZ_None: {
2719                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2720                 }
2721                 default: abort();
2722         }
2723 }
2724 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2725 CHECK(owner->result_ok);
2726         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2727 }
2728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2729         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2730         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2731         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2732         int64_t ret_ref = tag_ptr(ret_copy, true);
2733         return ret_ref;
2734 }
2735
2736 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2737 CHECK(!owner->result_ok);
2738         return DecodeError_clone(&*owner->contents.err);
2739 }
2740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2741         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2742         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2743         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2744         int64_t ret_ref = tag_ptr(ret_copy, true);
2745         return ret_ref;
2746 }
2747
2748 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2749 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2750 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2751 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2752 static jclass LDKHTLCDestination_InvalidForward_class = NULL;
2753 static jmethodID LDKHTLCDestination_InvalidForward_meth = NULL;
2754 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2755 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2757         LDKHTLCDestination_NextHopChannel_class =
2758                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2759         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2760         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2761         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2762         LDKHTLCDestination_UnknownNextHop_class =
2763                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2764         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2765         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2766         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2767         LDKHTLCDestination_InvalidForward_class =
2768                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$InvalidForward"));
2769         CHECK(LDKHTLCDestination_InvalidForward_class != NULL);
2770         LDKHTLCDestination_InvalidForward_meth = (*env)->GetMethodID(env, LDKHTLCDestination_InvalidForward_class, "<init>", "(J)V");
2771         CHECK(LDKHTLCDestination_InvalidForward_meth != NULL);
2772         LDKHTLCDestination_FailedPayment_class =
2773                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2774         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2775         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2776         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2777 }
2778 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2779         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
2780         switch(obj->tag) {
2781                 case LDKHTLCDestination_NextHopChannel: {
2782                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2783                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2784                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2785                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2786                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2787                 }
2788                 case LDKHTLCDestination_UnknownNextHop: {
2789                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2790                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2791                 }
2792                 case LDKHTLCDestination_InvalidForward: {
2793                         int64_t requested_forward_scid_conv = obj->invalid_forward.requested_forward_scid;
2794                         return (*env)->NewObject(env, LDKHTLCDestination_InvalidForward_class, LDKHTLCDestination_InvalidForward_meth, requested_forward_scid_conv);
2795                 }
2796                 case LDKHTLCDestination_FailedPayment: {
2797                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2798                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2799                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2800                 }
2801                 default: abort();
2802         }
2803 }
2804 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2805 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2806 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2807 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2809         LDKCOption_HTLCDestinationZ_Some_class =
2810                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2811         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2812         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2813         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2814         LDKCOption_HTLCDestinationZ_None_class =
2815                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2816         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2817         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2818         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2819 }
2820 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2821         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
2822         switch(obj->tag) {
2823                 case LDKCOption_HTLCDestinationZ_Some: {
2824                         int64_t some_ref = tag_ptr(&obj->some, false);
2825                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2826                 }
2827                 case LDKCOption_HTLCDestinationZ_None: {
2828                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2829                 }
2830                 default: abort();
2831         }
2832 }
2833 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2834 CHECK(owner->result_ok);
2835         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2836 }
2837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2838         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2839         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2840         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2841         int64_t ret_ref = tag_ptr(ret_copy, true);
2842         return ret_ref;
2843 }
2844
2845 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2846 CHECK(!owner->result_ok);
2847         return DecodeError_clone(&*owner->contents.err);
2848 }
2849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2850         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2851         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2852         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2853         int64_t ret_ref = tag_ptr(ret_copy, true);
2854         return ret_ref;
2855 }
2856
2857 static jclass LDKCOption_u128Z_Some_class = NULL;
2858 static jmethodID LDKCOption_u128Z_Some_meth = NULL;
2859 static jclass LDKCOption_u128Z_None_class = NULL;
2860 static jmethodID LDKCOption_u128Z_None_meth = NULL;
2861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u128Z_init (JNIEnv *env, jclass clz) {
2862         LDKCOption_u128Z_Some_class =
2863                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$Some"));
2864         CHECK(LDKCOption_u128Z_Some_class != NULL);
2865         LDKCOption_u128Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_Some_class, "<init>", "([B)V");
2866         CHECK(LDKCOption_u128Z_Some_meth != NULL);
2867         LDKCOption_u128Z_None_class =
2868                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$None"));
2869         CHECK(LDKCOption_u128Z_None_class != NULL);
2870         LDKCOption_u128Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_None_class, "<init>", "()V");
2871         CHECK(LDKCOption_u128Z_None_meth != NULL);
2872 }
2873 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u128Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2874         LDKCOption_u128Z *obj = (LDKCOption_u128Z*)untag_ptr(ptr);
2875         switch(obj->tag) {
2876                 case LDKCOption_u128Z_Some: {
2877                         int8_tArray some_arr = (*env)->NewByteArray(env, 16);
2878                         (*env)->SetByteArrayRegion(env, some_arr, 0, 16, obj->some.le_bytes);
2879                         return (*env)->NewObject(env, LDKCOption_u128Z_Some_class, LDKCOption_u128Z_Some_meth, some_arr);
2880                 }
2881                 case LDKCOption_u128Z_None: {
2882                         return (*env)->NewObject(env, LDKCOption_u128Z_None_class, LDKCOption_u128Z_None_meth);
2883                 }
2884                 default: abort();
2885         }
2886 }
2887 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2888 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2889 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2890 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2891 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2892 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2894         LDKNetworkUpdate_ChannelUpdateMessage_class =
2895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2896         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2897         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2898         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2899         LDKNetworkUpdate_ChannelFailure_class =
2900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2901         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2902         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2903         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2904         LDKNetworkUpdate_NodeFailure_class =
2905                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2906         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2907         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2908         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2909 }
2910 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2911         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
2912         switch(obj->tag) {
2913                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2914                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2915                         int64_t msg_ref = 0;
2916                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2917                         msg_ref = tag_ptr(msg_var.inner, false);
2918                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2919                 }
2920                 case LDKNetworkUpdate_ChannelFailure: {
2921                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2922                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2923                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2924                 }
2925                 case LDKNetworkUpdate_NodeFailure: {
2926                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2927                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2928                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2929                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2930                 }
2931                 default: abort();
2932         }
2933 }
2934 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2935 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2936 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2937 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2939         LDKCOption_NetworkUpdateZ_Some_class =
2940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2941         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2942         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2943         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2944         LDKCOption_NetworkUpdateZ_None_class =
2945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2946         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2947         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2948         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2949 }
2950 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2951         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
2952         switch(obj->tag) {
2953                 case LDKCOption_NetworkUpdateZ_Some: {
2954                         int64_t some_ref = tag_ptr(&obj->some, false);
2955                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2956                 }
2957                 case LDKCOption_NetworkUpdateZ_None: {
2958                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2959                 }
2960                 default: abort();
2961         }
2962 }
2963 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2964 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2965 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2966 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2967 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2968 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2970         LDKSpendableOutputDescriptor_StaticOutput_class =
2971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2972         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2973         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2974         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2975         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2976                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2977         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2978         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2979         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2980         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2981                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2982         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2983         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2984         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2985 }
2986 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2987         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
2988         switch(obj->tag) {
2989                 case LDKSpendableOutputDescriptor_StaticOutput: {
2990                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2991                         int64_t outpoint_ref = 0;
2992                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2993                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
2994                         LDKTxOut* output_ref = &obj->static_output.output;
2995                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
2996                 }
2997                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2998                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2999                         int64_t delayed_payment_output_ref = 0;
3000                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
3001                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
3002                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
3003                 }
3004                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
3005                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
3006                         int64_t static_payment_output_ref = 0;
3007                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
3008                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
3009                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
3010                 }
3011                 default: abort();
3012         }
3013 }
3014 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
3015         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
3016         for (size_t i = 0; i < ret.datalen; i++) {
3017                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
3018         }
3019         return ret;
3020 }
3021 static jclass LDKEvent_FundingGenerationReady_class = NULL;
3022 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
3023 static jclass LDKEvent_PaymentClaimable_class = NULL;
3024 static jmethodID LDKEvent_PaymentClaimable_meth = NULL;
3025 static jclass LDKEvent_PaymentClaimed_class = NULL;
3026 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
3027 static jclass LDKEvent_PaymentSent_class = NULL;
3028 static jmethodID LDKEvent_PaymentSent_meth = NULL;
3029 static jclass LDKEvent_PaymentFailed_class = NULL;
3030 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
3031 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
3032 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
3033 static jclass LDKEvent_PaymentPathFailed_class = NULL;
3034 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
3035 static jclass LDKEvent_ProbeSuccessful_class = NULL;
3036 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
3037 static jclass LDKEvent_ProbeFailed_class = NULL;
3038 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
3039 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
3040 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
3041 static jclass LDKEvent_HTLCIntercepted_class = NULL;
3042 static jmethodID LDKEvent_HTLCIntercepted_meth = NULL;
3043 static jclass LDKEvent_SpendableOutputs_class = NULL;
3044 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
3045 static jclass LDKEvent_PaymentForwarded_class = NULL;
3046 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
3047 static jclass LDKEvent_ChannelReady_class = NULL;
3048 static jmethodID LDKEvent_ChannelReady_meth = NULL;
3049 static jclass LDKEvent_ChannelClosed_class = NULL;
3050 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
3051 static jclass LDKEvent_DiscardFunding_class = NULL;
3052 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
3053 static jclass LDKEvent_OpenChannelRequest_class = NULL;
3054 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
3055 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
3056 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
3057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
3058         LDKEvent_FundingGenerationReady_class =
3059                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
3060         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
3061         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[B[B)V");
3062         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
3063         LDKEvent_PaymentClaimable_class =
3064                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimable"));
3065         CHECK(LDKEvent_PaymentClaimable_class != NULL);
3066         LDKEvent_PaymentClaimable_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimable_class, "<init>", "([B[BJJ[BJ)V");
3067         CHECK(LDKEvent_PaymentClaimable_meth != NULL);
3068         LDKEvent_PaymentClaimed_class =
3069                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
3070         CHECK(LDKEvent_PaymentClaimed_class != NULL);
3071         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([B[BJJ)V");
3072         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
3073         LDKEvent_PaymentSent_class =
3074                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
3075         CHECK(LDKEvent_PaymentSent_class != NULL);
3076         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
3077         CHECK(LDKEvent_PaymentSent_meth != NULL);
3078         LDKEvent_PaymentFailed_class =
3079                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
3080         CHECK(LDKEvent_PaymentFailed_class != NULL);
3081         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
3082         CHECK(LDKEvent_PaymentFailed_meth != NULL);
3083         LDKEvent_PaymentPathSuccessful_class =
3084                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
3085         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
3086         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
3087         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
3088         LDKEvent_PaymentPathFailed_class =
3089                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
3090         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
3091         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
3092         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
3093         LDKEvent_ProbeSuccessful_class =
3094                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
3095         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
3096         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
3097         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
3098         LDKEvent_ProbeFailed_class =
3099                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
3100         CHECK(LDKEvent_ProbeFailed_class != NULL);
3101         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
3102         CHECK(LDKEvent_ProbeFailed_meth != NULL);
3103         LDKEvent_PendingHTLCsForwardable_class =
3104                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
3105         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
3106         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
3107         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
3108         LDKEvent_HTLCIntercepted_class =
3109                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCIntercepted"));
3110         CHECK(LDKEvent_HTLCIntercepted_class != NULL);
3111         LDKEvent_HTLCIntercepted_meth = (*env)->GetMethodID(env, LDKEvent_HTLCIntercepted_class, "<init>", "([BJ[BJJ)V");
3112         CHECK(LDKEvent_HTLCIntercepted_meth != NULL);
3113         LDKEvent_SpendableOutputs_class =
3114                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
3115         CHECK(LDKEvent_SpendableOutputs_class != NULL);
3116         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
3117         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
3118         LDKEvent_PaymentForwarded_class =
3119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
3120         CHECK(LDKEvent_PaymentForwarded_class != NULL);
3121         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
3122         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
3123         LDKEvent_ChannelReady_class =
3124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelReady"));
3125         CHECK(LDKEvent_ChannelReady_class != NULL);
3126         LDKEvent_ChannelReady_meth = (*env)->GetMethodID(env, LDKEvent_ChannelReady_class, "<init>", "([B[B[BJ)V");
3127         CHECK(LDKEvent_ChannelReady_meth != NULL);
3128         LDKEvent_ChannelClosed_class =
3129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
3130         CHECK(LDKEvent_ChannelClosed_class != NULL);
3131         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([B[BJ)V");
3132         CHECK(LDKEvent_ChannelClosed_meth != NULL);
3133         LDKEvent_DiscardFunding_class =
3134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
3135         CHECK(LDKEvent_DiscardFunding_class != NULL);
3136         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
3137         CHECK(LDKEvent_DiscardFunding_meth != NULL);
3138         LDKEvent_OpenChannelRequest_class =
3139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
3140         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
3141         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
3142         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
3143         LDKEvent_HTLCHandlingFailed_class =
3144                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
3145         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
3146         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
3147         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
3148 }
3149 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3150         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
3151         switch(obj->tag) {
3152                 case LDKEvent_FundingGenerationReady: {
3153                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3154                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
3155                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3156                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
3157                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
3158                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3159                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
3160                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
3161                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3162                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->funding_generation_ready.user_channel_id.le_bytes);
3163                         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);
3164                 }
3165                 case LDKEvent_PaymentClaimable: {
3166                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
3167                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimable.receiver_node_id.compressed_form);
3168                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3169                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimable.payment_hash.data);
3170                         int64_t amount_msat_conv = obj->payment_claimable.amount_msat;
3171                         int64_t purpose_ref = tag_ptr(&obj->payment_claimable.purpose, false);
3172                         int8_tArray via_channel_id_arr = (*env)->NewByteArray(env, 32);
3173                         (*env)->SetByteArrayRegion(env, via_channel_id_arr, 0, 32, obj->payment_claimable.via_channel_id.data);
3174                         int64_t via_user_channel_id_ref = tag_ptr(&obj->payment_claimable.via_user_channel_id, false);
3175                         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);
3176                 }
3177                 case LDKEvent_PaymentClaimed: {
3178                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
3179                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimed.receiver_node_id.compressed_form);
3180                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3181                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
3182                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
3183                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
3184                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, receiver_node_id_arr, payment_hash_arr, amount_msat_conv, purpose_ref);
3185                 }
3186                 case LDKEvent_PaymentSent: {
3187                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3188                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
3189                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3190                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
3191                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3192                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
3193                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
3194                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
3195                 }
3196                 case LDKEvent_PaymentFailed: {
3197                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3198                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
3199                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3200                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
3201                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
3202                 }
3203                 case LDKEvent_PaymentPathSuccessful: {
3204                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3205                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
3206                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3207                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
3208                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
3209                         int64_tArray path_arr = NULL;
3210                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3211                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3212                         for (size_t k = 0; k < path_var.datalen; k++) {
3213                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3214                                 int64_t path_conv_10_ref = 0;
3215                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3216                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3217                                 path_arr_ptr[k] = path_conv_10_ref;
3218                         }
3219                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3220                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3221                 }
3222                 case LDKEvent_PaymentPathFailed: {
3223                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3224                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
3225                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3226                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
3227                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
3228                         int64_t network_update_ref = tag_ptr(&obj->payment_path_failed.network_update, false);
3229                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
3230                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3231                         int64_tArray path_arr = NULL;
3232                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3233                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3234                         for (size_t k = 0; k < path_var.datalen; k++) {
3235                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3236                                 int64_t path_conv_10_ref = 0;
3237                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3238                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3239                                 path_arr_ptr[k] = path_conv_10_ref;
3240                         }
3241                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3242                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
3243                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
3244                         int64_t retry_ref = 0;
3245                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
3246                         retry_ref = tag_ptr(retry_var.inner, false);
3247                         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);
3248                 }
3249                 case LDKEvent_ProbeSuccessful: {
3250                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3251                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
3252                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3253                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
3254                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
3255                         int64_tArray path_arr = NULL;
3256                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3257                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3258                         for (size_t k = 0; k < path_var.datalen; k++) {
3259                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3260                                 int64_t path_conv_10_ref = 0;
3261                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3262                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3263                                 path_arr_ptr[k] = path_conv_10_ref;
3264                         }
3265                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3266                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3267                 }
3268                 case LDKEvent_ProbeFailed: {
3269                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3270                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
3271                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3272                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
3273                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
3274                         int64_tArray path_arr = NULL;
3275                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3276                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3277                         for (size_t k = 0; k < path_var.datalen; k++) {
3278                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3279                                 int64_t path_conv_10_ref = 0;
3280                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3281                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3282                                 path_arr_ptr[k] = path_conv_10_ref;
3283                         }
3284                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3285                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
3286                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
3287                 }
3288                 case LDKEvent_PendingHTLCsForwardable: {
3289                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
3290                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
3291                 }
3292                 case LDKEvent_HTLCIntercepted: {
3293                         int8_tArray intercept_id_arr = (*env)->NewByteArray(env, 32);
3294                         (*env)->SetByteArrayRegion(env, intercept_id_arr, 0, 32, obj->htlc_intercepted.intercept_id.data);
3295                         int64_t requested_next_hop_scid_conv = obj->htlc_intercepted.requested_next_hop_scid;
3296                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3297                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->htlc_intercepted.payment_hash.data);
3298                         int64_t inbound_amount_msat_conv = obj->htlc_intercepted.inbound_amount_msat;
3299                         int64_t expected_outbound_amount_msat_conv = obj->htlc_intercepted.expected_outbound_amount_msat;
3300                         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);
3301                 }
3302                 case LDKEvent_SpendableOutputs: {
3303                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3304                         int64_tArray outputs_arr = NULL;
3305                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
3306                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
3307                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3308                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
3309                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3310                         }
3311                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
3312                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
3313                 }
3314                 case LDKEvent_PaymentForwarded: {
3315                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3316                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
3317                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
3318                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
3319                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
3320                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
3321                         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);
3322                 }
3323                 case LDKEvent_ChannelReady: {
3324                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3325                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_ready.channel_id.data);
3326                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3327                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_ready.user_channel_id.le_bytes);
3328                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3329                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->channel_ready.counterparty_node_id.compressed_form);
3330                         LDKChannelTypeFeatures channel_type_var = obj->channel_ready.channel_type;
3331                         int64_t channel_type_ref = 0;
3332                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3333                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3334                         return (*env)->NewObject(env, LDKEvent_ChannelReady_class, LDKEvent_ChannelReady_meth, channel_id_arr, user_channel_id_arr, counterparty_node_id_arr, channel_type_ref);
3335                 }
3336                 case LDKEvent_ChannelClosed: {
3337                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3338                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
3339                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3340                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_closed.user_channel_id.le_bytes);
3341                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
3342                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_arr, reason_ref);
3343                 }
3344                 case LDKEvent_DiscardFunding: {
3345                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3346                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
3347                         LDKTransaction transaction_var = obj->discard_funding.transaction;
3348                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
3349                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
3350                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
3351                 }
3352                 case LDKEvent_OpenChannelRequest: {
3353                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3354                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
3355                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3356                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
3357                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
3358                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
3359                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
3360                         int64_t channel_type_ref = 0;
3361                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3362                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3363                         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);
3364                 }
3365                 case LDKEvent_HTLCHandlingFailed: {
3366                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3367                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
3368                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
3369                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
3370                 }
3371                 default: abort();
3372         }
3373 }
3374 static jclass LDKCOption_EventZ_Some_class = NULL;
3375 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
3376 static jclass LDKCOption_EventZ_None_class = NULL;
3377 static jmethodID LDKCOption_EventZ_None_meth = NULL;
3378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
3379         LDKCOption_EventZ_Some_class =
3380                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
3381         CHECK(LDKCOption_EventZ_Some_class != NULL);
3382         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
3383         CHECK(LDKCOption_EventZ_Some_meth != NULL);
3384         LDKCOption_EventZ_None_class =
3385                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
3386         CHECK(LDKCOption_EventZ_None_class != NULL);
3387         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
3388         CHECK(LDKCOption_EventZ_None_meth != NULL);
3389 }
3390 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3391         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
3392         switch(obj->tag) {
3393                 case LDKCOption_EventZ_Some: {
3394                         int64_t some_ref = tag_ptr(&obj->some, false);
3395                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
3396                 }
3397                 case LDKCOption_EventZ_None: {
3398                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
3399                 }
3400                 default: abort();
3401         }
3402 }
3403 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3404 CHECK(owner->result_ok);
3405         return COption_EventZ_clone(&*owner->contents.result);
3406 }
3407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3408         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3409         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3410         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3411         int64_t ret_ref = tag_ptr(ret_copy, true);
3412         return ret_ref;
3413 }
3414
3415 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3416 CHECK(!owner->result_ok);
3417         return DecodeError_clone(&*owner->contents.err);
3418 }
3419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3420         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3421         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3422         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3423         int64_t ret_ref = tag_ptr(ret_copy, true);
3424         return ret_ref;
3425 }
3426
3427 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
3428 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
3429 static jclass LDKErrorAction_IgnoreError_class = NULL;
3430 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
3431 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
3432 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
3433 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
3434 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
3435 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
3436 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
3437 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
3438 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
3439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
3440         LDKErrorAction_DisconnectPeer_class =
3441                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
3442         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
3443         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
3444         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
3445         LDKErrorAction_IgnoreError_class =
3446                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
3447         CHECK(LDKErrorAction_IgnoreError_class != NULL);
3448         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
3449         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
3450         LDKErrorAction_IgnoreAndLog_class =
3451                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
3452         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
3453         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
3454         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
3455         LDKErrorAction_IgnoreDuplicateGossip_class =
3456                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
3457         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
3458         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
3459         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
3460         LDKErrorAction_SendErrorMessage_class =
3461                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
3462         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
3463         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
3464         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
3465         LDKErrorAction_SendWarningMessage_class =
3466                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
3467         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
3468         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
3469         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
3470 }
3471 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3472         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
3473         switch(obj->tag) {
3474                 case LDKErrorAction_DisconnectPeer: {
3475                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
3476                         int64_t msg_ref = 0;
3477                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3478                         msg_ref = tag_ptr(msg_var.inner, false);
3479                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
3480                 }
3481                 case LDKErrorAction_IgnoreError: {
3482                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
3483                 }
3484                 case LDKErrorAction_IgnoreAndLog: {
3485                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
3486                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
3487                 }
3488                 case LDKErrorAction_IgnoreDuplicateGossip: {
3489                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
3490                 }
3491                 case LDKErrorAction_SendErrorMessage: {
3492                         LDKErrorMessage msg_var = obj->send_error_message.msg;
3493                         int64_t msg_ref = 0;
3494                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3495                         msg_ref = tag_ptr(msg_var.inner, false);
3496                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
3497                 }
3498                 case LDKErrorAction_SendWarningMessage: {
3499                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
3500                         int64_t msg_ref = 0;
3501                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3502                         msg_ref = tag_ptr(msg_var.inner, false);
3503                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
3504                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
3505                 }
3506                 default: abort();
3507         }
3508 }
3509 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
3510 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
3511 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
3512 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
3513 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
3514 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
3515 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
3516 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
3517 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
3518 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
3519 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
3520 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
3521 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
3522 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
3523 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
3524 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
3525 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
3526 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
3527 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
3528 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
3529 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
3530 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
3531 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
3532 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
3533 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
3534 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
3535 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
3536 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
3537 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
3538 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
3539 static jclass LDKMessageSendEvent_HandleError_class = NULL;
3540 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
3541 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
3542 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
3543 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
3544 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
3545 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
3546 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
3547 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
3548 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
3549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
3550         LDKMessageSendEvent_SendAcceptChannel_class =
3551                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
3552         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
3553         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
3554         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
3555         LDKMessageSendEvent_SendOpenChannel_class =
3556                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
3557         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
3558         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
3559         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
3560         LDKMessageSendEvent_SendFundingCreated_class =
3561                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
3562         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
3563         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
3564         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
3565         LDKMessageSendEvent_SendFundingSigned_class =
3566                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
3567         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
3568         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
3569         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
3570         LDKMessageSendEvent_SendChannelReady_class =
3571                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
3572         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
3573         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
3574         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
3575         LDKMessageSendEvent_SendAnnouncementSignatures_class =
3576                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
3577         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
3578         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
3579         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
3580         LDKMessageSendEvent_UpdateHTLCs_class =
3581                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
3582         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
3583         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
3584         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
3585         LDKMessageSendEvent_SendRevokeAndACK_class =
3586                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
3587         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
3588         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
3589         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
3590         LDKMessageSendEvent_SendClosingSigned_class =
3591                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
3592         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
3593         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
3594         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
3595         LDKMessageSendEvent_SendShutdown_class =
3596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
3597         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
3598         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
3599         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
3600         LDKMessageSendEvent_SendChannelReestablish_class =
3601                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
3602         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
3603         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
3604         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
3605         LDKMessageSendEvent_SendChannelAnnouncement_class =
3606                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
3607         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
3608         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
3609         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
3610         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
3611                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
3612         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
3613         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
3614         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
3615         LDKMessageSendEvent_BroadcastChannelUpdate_class =
3616                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
3617         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
3618         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
3619         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
3620         LDKMessageSendEvent_SendChannelUpdate_class =
3621                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
3622         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
3623         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
3624         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
3625         LDKMessageSendEvent_HandleError_class =
3626                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
3627         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
3628         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
3629         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
3630         LDKMessageSendEvent_SendChannelRangeQuery_class =
3631                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
3632         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
3633         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
3634         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
3635         LDKMessageSendEvent_SendShortIdsQuery_class =
3636                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
3637         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
3638         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
3639         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
3640         LDKMessageSendEvent_SendReplyChannelRange_class =
3641                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
3642         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
3643         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
3644         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
3645         LDKMessageSendEvent_SendGossipTimestampFilter_class =
3646                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
3647         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
3648         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
3649         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
3650 }
3651 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3652         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
3653         switch(obj->tag) {
3654                 case LDKMessageSendEvent_SendAcceptChannel: {
3655                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3656                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
3657                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
3658                         int64_t msg_ref = 0;
3659                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3660                         msg_ref = tag_ptr(msg_var.inner, false);
3661                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3662                 }
3663                 case LDKMessageSendEvent_SendOpenChannel: {
3664                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3665                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3666                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3667                         int64_t msg_ref = 0;
3668                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3669                         msg_ref = tag_ptr(msg_var.inner, false);
3670                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3671                 }
3672                 case LDKMessageSendEvent_SendFundingCreated: {
3673                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3674                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3675                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3676                         int64_t msg_ref = 0;
3677                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3678                         msg_ref = tag_ptr(msg_var.inner, false);
3679                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3680                 }
3681                 case LDKMessageSendEvent_SendFundingSigned: {
3682                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3683                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3684                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3685                         int64_t msg_ref = 0;
3686                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3687                         msg_ref = tag_ptr(msg_var.inner, false);
3688                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3689                 }
3690                 case LDKMessageSendEvent_SendChannelReady: {
3691                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3692                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3693                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3694                         int64_t msg_ref = 0;
3695                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3696                         msg_ref = tag_ptr(msg_var.inner, false);
3697                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3698                 }
3699                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3700                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3701                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3702                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3703                         int64_t msg_ref = 0;
3704                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3705                         msg_ref = tag_ptr(msg_var.inner, false);
3706                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3707                 }
3708                 case LDKMessageSendEvent_UpdateHTLCs: {
3709                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3710                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3711                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3712                         int64_t updates_ref = 0;
3713                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3714                         updates_ref = tag_ptr(updates_var.inner, false);
3715                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3716                 }
3717                 case LDKMessageSendEvent_SendRevokeAndACK: {
3718                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3719                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3720                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3721                         int64_t msg_ref = 0;
3722                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3723                         msg_ref = tag_ptr(msg_var.inner, false);
3724                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3725                 }
3726                 case LDKMessageSendEvent_SendClosingSigned: {
3727                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3728                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3729                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3730                         int64_t msg_ref = 0;
3731                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3732                         msg_ref = tag_ptr(msg_var.inner, false);
3733                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3734                 }
3735                 case LDKMessageSendEvent_SendShutdown: {
3736                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3737                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3738                         LDKShutdown msg_var = obj->send_shutdown.msg;
3739                         int64_t msg_ref = 0;
3740                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3741                         msg_ref = tag_ptr(msg_var.inner, false);
3742                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3743                 }
3744                 case LDKMessageSendEvent_SendChannelReestablish: {
3745                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3746                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3747                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3748                         int64_t msg_ref = 0;
3749                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3750                         msg_ref = tag_ptr(msg_var.inner, false);
3751                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3752                 }
3753                 case LDKMessageSendEvent_SendChannelAnnouncement: {
3754                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3755                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
3756                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
3757                         int64_t msg_ref = 0;
3758                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3759                         msg_ref = tag_ptr(msg_var.inner, false);
3760                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
3761                         int64_t update_msg_ref = 0;
3762                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3763                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3764                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
3765                 }
3766                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3767                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3768                         int64_t msg_ref = 0;
3769                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3770                         msg_ref = tag_ptr(msg_var.inner, false);
3771                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3772                         int64_t update_msg_ref = 0;
3773                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3774                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3775                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3776                 }
3777                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3778                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3779                         int64_t msg_ref = 0;
3780                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3781                         msg_ref = tag_ptr(msg_var.inner, false);
3782                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3783                 }
3784                 case LDKMessageSendEvent_SendChannelUpdate: {
3785                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3786                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3787                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3788                         int64_t msg_ref = 0;
3789                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3790                         msg_ref = tag_ptr(msg_var.inner, false);
3791                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3792                 }
3793                 case LDKMessageSendEvent_HandleError: {
3794                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3795                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3796                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
3797                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3798                 }
3799                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3800                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3801                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3802                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3803                         int64_t msg_ref = 0;
3804                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3805                         msg_ref = tag_ptr(msg_var.inner, false);
3806                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3807                 }
3808                 case LDKMessageSendEvent_SendShortIdsQuery: {
3809                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3810                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3811                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3812                         int64_t msg_ref = 0;
3813                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3814                         msg_ref = tag_ptr(msg_var.inner, false);
3815                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3816                 }
3817                 case LDKMessageSendEvent_SendReplyChannelRange: {
3818                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3819                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3820                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3821                         int64_t msg_ref = 0;
3822                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3823                         msg_ref = tag_ptr(msg_var.inner, false);
3824                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3825                 }
3826                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3827                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3828                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3829                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3830                         int64_t msg_ref = 0;
3831                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3832                         msg_ref = tag_ptr(msg_var.inner, false);
3833                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3834                 }
3835                 default: abort();
3836         }
3837 }
3838 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3839         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3840         for (size_t i = 0; i < ret.datalen; i++) {
3841                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3842         }
3843         return ret;
3844 }
3845 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3846 CHECK(owner->result_ok);
3847         return TxOut_clone(&*owner->contents.result);
3848 }
3849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3850         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3851         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3852         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3853         return tag_ptr(ret_ref, true);
3854 }
3855
3856 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3857 CHECK(!owner->result_ok);
3858         return AccessError_clone(&*owner->contents.err);
3859 }
3860 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3861         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3862         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3863         return ret_conv;
3864 }
3865
3866 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3867         return owner->a;
3868 }
3869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3870         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3871         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3872         return ret_conv;
3873 }
3874
3875 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3876         return owner->b;
3877 }
3878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3879         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3880         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3881         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3882         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3883         return ret_arr;
3884 }
3885
3886 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3887         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3888         for (size_t i = 0; i < ret.datalen; i++) {
3889                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3890         }
3891         return ret;
3892 }
3893 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_a(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
3894         return ThirtyTwoBytes_clone(&owner->a);
3895 }
3896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3897         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
3898         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_a(owner_conv).data);
3900         return ret_arr;
3901 }
3902
3903 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_b(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
3904         return ThirtyTwoBytes_clone(&owner->b);
3905 }
3906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3907         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
3908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_b(owner_conv).data);
3910         return ret_arr;
3911 }
3912
3913 static inline LDKCVec_C2Tuple_TxidBlockHashZZ CVec_C2Tuple_TxidBlockHashZZ_clone(const LDKCVec_C2Tuple_TxidBlockHashZZ *orig) {
3914         LDKCVec_C2Tuple_TxidBlockHashZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ) * orig->datalen, "LDKCVec_C2Tuple_TxidBlockHashZZ clone bytes"), .datalen = orig->datalen };
3915         for (size_t i = 0; i < ret.datalen; i++) {
3916                 ret.data[i] = C2Tuple_TxidBlockHashZ_clone(&orig->data[i]);
3917         }
3918         return ret;
3919 }
3920 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3921 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3922 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3923 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3924 static jclass LDKMonitorEvent_Completed_class = NULL;
3925 static jmethodID LDKMonitorEvent_Completed_meth = NULL;
3926 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3927 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3929         LDKMonitorEvent_HTLCEvent_class =
3930                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3931         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3932         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3933         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3934         LDKMonitorEvent_CommitmentTxConfirmed_class =
3935                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3936         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3937         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3938         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3939         LDKMonitorEvent_Completed_class =
3940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$Completed"));
3941         CHECK(LDKMonitorEvent_Completed_class != NULL);
3942         LDKMonitorEvent_Completed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_Completed_class, "<init>", "(JJ)V");
3943         CHECK(LDKMonitorEvent_Completed_meth != NULL);
3944         LDKMonitorEvent_UpdateFailed_class =
3945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3946         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3947         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3948         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3949 }
3950 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3951         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3952         switch(obj->tag) {
3953                 case LDKMonitorEvent_HTLCEvent: {
3954                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3955                         int64_t htlc_event_ref = 0;
3956                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3957                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3958                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3959                 }
3960                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3961                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3962                         int64_t commitment_tx_confirmed_ref = 0;
3963                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3964                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
3965                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3966                 }
3967                 case LDKMonitorEvent_Completed: {
3968                         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
3969                         int64_t funding_txo_ref = 0;
3970                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3971                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3972                         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
3973                         return (*env)->NewObject(env, LDKMonitorEvent_Completed_class, LDKMonitorEvent_Completed_meth, funding_txo_ref, monitor_update_id_conv);
3974                 }
3975                 case LDKMonitorEvent_UpdateFailed: {
3976                         LDKOutPoint update_failed_var = obj->update_failed;
3977                         int64_t update_failed_ref = 0;
3978                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3979                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
3980                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3981                 }
3982                 default: abort();
3983         }
3984 }
3985 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3986         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3987         for (size_t i = 0; i < ret.datalen; i++) {
3988                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3989         }
3990         return ret;
3991 }
3992 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3993         LDKOutPoint ret = owner->a;
3994         ret.is_owned = false;
3995         return ret;
3996 }
3997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3998         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3999         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
4000         int64_t ret_ref = 0;
4001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4002         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4003         return ret_ref;
4004 }
4005
4006 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
4007         return CVec_MonitorEventZ_clone(&owner->b);
4008 }
4009 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4010         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4011         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
4012         int64_tArray ret_arr = NULL;
4013         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4014         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4015         for (size_t o = 0; o < ret_var.datalen; o++) {
4016                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4017                 *ret_conv_14_copy = ret_var.data[o];
4018                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
4019                 ret_arr_ptr[o] = ret_conv_14_ref;
4020         }
4021         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4022         FREE(ret_var.data);
4023         return ret_arr;
4024 }
4025
4026 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
4027         return owner->c;
4028 }
4029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4030         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4031         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4032         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
4033         return ret_arr;
4034 }
4035
4036 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
4037         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
4038         for (size_t i = 0; i < ret.datalen; i++) {
4039                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
4040         }
4041         return ret;
4042 }
4043 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
4044         LDKFixedPenaltyScorer ret = *owner->contents.result;
4045         ret.is_owned = false;
4046         return ret;
4047 }
4048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4049         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
4050         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
4051         int64_t ret_ref = 0;
4052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4054         return ret_ref;
4055 }
4056
4057 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
4058 CHECK(!owner->result_ok);
4059         return DecodeError_clone(&*owner->contents.err);
4060 }
4061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4062         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
4063         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4064         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
4065         int64_t ret_ref = tag_ptr(ret_copy, true);
4066         return ret_ref;
4067 }
4068
4069 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4070         return owner->a;
4071 }
4072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4073         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4074         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
4075         return ret_conv;
4076 }
4077
4078 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4079         return owner->b;
4080 }
4081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4082         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4083         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
4084         return ret_conv;
4085 }
4086
4087 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
4088 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
4089 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
4090 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
4091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
4092         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
4093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
4094         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
4095         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
4096         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
4097         LDKCOption_C2Tuple_u64u64ZZ_None_class =
4098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
4099         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
4100         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
4101         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
4102 }
4103 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4104         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
4105         switch(obj->tag) {
4106                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
4107                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4108                         *some_conv = obj->some;
4109                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
4110                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
4111                 }
4112                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
4113                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
4114                 }
4115                 default: abort();
4116         }
4117 }
4118 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
4119         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
4120         for (size_t i = 0; i < ret.datalen; i++) {
4121                 ret.data[i] = NodeId_clone(&orig->data[i]);
4122         }
4123         return ret;
4124 }
4125 typedef struct LDKLogger_JCalls {
4126         atomic_size_t refcnt;
4127         JavaVM *vm;
4128         jweak o;
4129         jmethodID log_meth;
4130 } LDKLogger_JCalls;
4131 static void LDKLogger_JCalls_free(void* this_arg) {
4132         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4133         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4134                 JNIEnv *env;
4135                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4136                 if (get_jenv_res == JNI_EDETACHED) {
4137                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4138                 } else {
4139                         DO_ASSERT(get_jenv_res == JNI_OK);
4140                 }
4141                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4142                 if (get_jenv_res == JNI_EDETACHED) {
4143                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4144                 }
4145                 FREE(j_calls);
4146         }
4147 }
4148 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4149         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4150         JNIEnv *env;
4151         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4152         if (get_jenv_res == JNI_EDETACHED) {
4153                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4154         } else {
4155                 DO_ASSERT(get_jenv_res == JNI_OK);
4156         }
4157         LDKRecord record_var = *record;
4158         int64_t record_ref = 0;
4159         record_var = Record_clone(&record_var);
4160         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4161         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
4162         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4163         CHECK(obj != NULL);
4164         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4165         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4166                 (*env)->ExceptionDescribe(env);
4167                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4168         }
4169         if (get_jenv_res == JNI_EDETACHED) {
4170                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4171         }
4172 }
4173 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4174         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4175         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4176 }
4177 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4178         jclass c = (*env)->GetObjectClass(env, o);
4179         CHECK(c != NULL);
4180         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4181         atomic_init(&calls->refcnt, 1);
4182         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4183         calls->o = (*env)->NewWeakGlobalRef(env, o);
4184         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4185         CHECK(calls->log_meth != NULL);
4186
4187         LDKLogger ret = {
4188                 .this_arg = (void*) calls,
4189                 .log = log_LDKLogger_jcall,
4190                 .free = LDKLogger_JCalls_free,
4191         };
4192         return ret;
4193 }
4194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4195         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4196         *res_ptr = LDKLogger_init(env, clz, o);
4197         return tag_ptr(res_ptr, true);
4198 }
4199 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4200         LDKProbabilisticScorer ret = *owner->contents.result;
4201         ret.is_owned = false;
4202         return ret;
4203 }
4204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4205         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4206         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
4207         int64_t ret_ref = 0;
4208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4210         return ret_ref;
4211 }
4212
4213 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4214 CHECK(!owner->result_ok);
4215         return DecodeError_clone(&*owner->contents.err);
4216 }
4217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4218         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4219         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4220         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
4221         int64_t ret_ref = tag_ptr(ret_copy, true);
4222         return ret_ref;
4223 }
4224
4225 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4226         LDKInitFeatures ret = *owner->contents.result;
4227         ret.is_owned = false;
4228         return ret;
4229 }
4230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4231         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4232         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4233         int64_t ret_ref = 0;
4234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4236         return ret_ref;
4237 }
4238
4239 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4240 CHECK(!owner->result_ok);
4241         return DecodeError_clone(&*owner->contents.err);
4242 }
4243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4244         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4245         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4246         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4247         int64_t ret_ref = tag_ptr(ret_copy, true);
4248         return ret_ref;
4249 }
4250
4251 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4252         LDKChannelFeatures ret = *owner->contents.result;
4253         ret.is_owned = false;
4254         return ret;
4255 }
4256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4257         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4258         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4259         int64_t ret_ref = 0;
4260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4262         return ret_ref;
4263 }
4264
4265 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4266 CHECK(!owner->result_ok);
4267         return DecodeError_clone(&*owner->contents.err);
4268 }
4269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4270         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4271         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4272         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4273         int64_t ret_ref = tag_ptr(ret_copy, true);
4274         return ret_ref;
4275 }
4276
4277 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4278         LDKNodeFeatures ret = *owner->contents.result;
4279         ret.is_owned = false;
4280         return ret;
4281 }
4282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4283         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4284         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4285         int64_t ret_ref = 0;
4286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4288         return ret_ref;
4289 }
4290
4291 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4292 CHECK(!owner->result_ok);
4293         return DecodeError_clone(&*owner->contents.err);
4294 }
4295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4296         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4297         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4298         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4299         int64_t ret_ref = tag_ptr(ret_copy, true);
4300         return ret_ref;
4301 }
4302
4303 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4304         LDKInvoiceFeatures ret = *owner->contents.result;
4305         ret.is_owned = false;
4306         return ret;
4307 }
4308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4309         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4310         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4311         int64_t ret_ref = 0;
4312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4314         return ret_ref;
4315 }
4316
4317 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4318 CHECK(!owner->result_ok);
4319         return DecodeError_clone(&*owner->contents.err);
4320 }
4321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4322         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4323         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4324         *ret_copy = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4325         int64_t ret_ref = tag_ptr(ret_copy, true);
4326         return ret_ref;
4327 }
4328
4329 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4330         LDKChannelTypeFeatures ret = *owner->contents.result;
4331         ret.is_owned = false;
4332         return ret;
4333 }
4334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4335         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4336         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4337         int64_t ret_ref = 0;
4338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4340         return ret_ref;
4341 }
4342
4343 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4344 CHECK(!owner->result_ok);
4345         return DecodeError_clone(&*owner->contents.err);
4346 }
4347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4348         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4349         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4350         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4351         int64_t ret_ref = tag_ptr(ret_copy, true);
4352         return ret_ref;
4353 }
4354
4355 static inline struct LDKOfferFeatures CResult_OfferFeaturesDecodeErrorZ_get_ok(LDKCResult_OfferFeaturesDecodeErrorZ *NONNULL_PTR owner){
4356         LDKOfferFeatures ret = *owner->contents.result;
4357         ret.is_owned = false;
4358         return ret;
4359 }
4360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4361         LDKCResult_OfferFeaturesDecodeErrorZ* owner_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(owner);
4362         LDKOfferFeatures ret_var = CResult_OfferFeaturesDecodeErrorZ_get_ok(owner_conv);
4363         int64_t ret_ref = 0;
4364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4366         return ret_ref;
4367 }
4368
4369 static inline struct LDKDecodeError CResult_OfferFeaturesDecodeErrorZ_get_err(LDKCResult_OfferFeaturesDecodeErrorZ *NONNULL_PTR owner){
4370 CHECK(!owner->result_ok);
4371         return DecodeError_clone(&*owner->contents.err);
4372 }
4373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4374         LDKCResult_OfferFeaturesDecodeErrorZ* owner_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(owner);
4375         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4376         *ret_copy = CResult_OfferFeaturesDecodeErrorZ_get_err(owner_conv);
4377         int64_t ret_ref = tag_ptr(ret_copy, true);
4378         return ret_ref;
4379 }
4380
4381 static inline struct LDKInvoiceRequestFeatures CResult_InvoiceRequestFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ *NONNULL_PTR owner){
4382         LDKInvoiceRequestFeatures ret = *owner->contents.result;
4383         ret.is_owned = false;
4384         return ret;
4385 }
4386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4387         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(owner);
4388         LDKInvoiceRequestFeatures ret_var = CResult_InvoiceRequestFeaturesDecodeErrorZ_get_ok(owner_conv);
4389         int64_t ret_ref = 0;
4390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4391         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4392         return ret_ref;
4393 }
4394
4395 static inline struct LDKDecodeError CResult_InvoiceRequestFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ *NONNULL_PTR owner){
4396 CHECK(!owner->result_ok);
4397         return DecodeError_clone(&*owner->contents.err);
4398 }
4399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4400         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(owner);
4401         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4402         *ret_copy = CResult_InvoiceRequestFeaturesDecodeErrorZ_get_err(owner_conv);
4403         int64_t ret_ref = tag_ptr(ret_copy, true);
4404         return ret_ref;
4405 }
4406
4407 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4408         LDKNodeId ret = *owner->contents.result;
4409         ret.is_owned = false;
4410         return ret;
4411 }
4412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4413         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4414         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4415         int64_t ret_ref = 0;
4416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4418         return ret_ref;
4419 }
4420
4421 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4422 CHECK(!owner->result_ok);
4423         return DecodeError_clone(&*owner->contents.err);
4424 }
4425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4426         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4427         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4428         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4429         int64_t ret_ref = tag_ptr(ret_copy, true);
4430         return ret_ref;
4431 }
4432
4433 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4434 CHECK(owner->result_ok);
4435         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4436 }
4437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4438         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4439         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4440         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4441         int64_t ret_ref = tag_ptr(ret_copy, true);
4442         return ret_ref;
4443 }
4444
4445 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4446 CHECK(!owner->result_ok);
4447         return DecodeError_clone(&*owner->contents.err);
4448 }
4449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4450         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4451         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4452         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4453         int64_t ret_ref = tag_ptr(ret_copy, true);
4454         return ret_ref;
4455 }
4456
4457 typedef struct LDKAccess_JCalls {
4458         atomic_size_t refcnt;
4459         JavaVM *vm;
4460         jweak o;
4461         jmethodID get_utxo_meth;
4462 } LDKAccess_JCalls;
4463 static void LDKAccess_JCalls_free(void* this_arg) {
4464         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4465         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4466                 JNIEnv *env;
4467                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4468                 if (get_jenv_res == JNI_EDETACHED) {
4469                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4470                 } else {
4471                         DO_ASSERT(get_jenv_res == JNI_OK);
4472                 }
4473                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4474                 if (get_jenv_res == JNI_EDETACHED) {
4475                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4476                 }
4477                 FREE(j_calls);
4478         }
4479 }
4480 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4481         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4482         JNIEnv *env;
4483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4484         if (get_jenv_res == JNI_EDETACHED) {
4485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4486         } else {
4487                 DO_ASSERT(get_jenv_res == JNI_OK);
4488         }
4489         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4490         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4491         int64_t short_channel_id_conv = short_channel_id;
4492         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4493         CHECK(obj != NULL);
4494         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
4495         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4496                 (*env)->ExceptionDescribe(env);
4497                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
4498         }
4499         void* ret_ptr = untag_ptr(ret);
4500         CHECK_ACCESS(ret_ptr);
4501         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4502         FREE(untag_ptr(ret));
4503         if (get_jenv_res == JNI_EDETACHED) {
4504                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4505         }
4506         return ret_conv;
4507 }
4508 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4509         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4510         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4511 }
4512 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4513         jclass c = (*env)->GetObjectClass(env, o);
4514         CHECK(c != NULL);
4515         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4516         atomic_init(&calls->refcnt, 1);
4517         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4518         calls->o = (*env)->NewWeakGlobalRef(env, o);
4519         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4520         CHECK(calls->get_utxo_meth != NULL);
4521
4522         LDKAccess ret = {
4523                 .this_arg = (void*) calls,
4524                 .get_utxo = get_utxo_LDKAccess_jcall,
4525                 .free = LDKAccess_JCalls_free,
4526         };
4527         return ret;
4528 }
4529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4530         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4531         *res_ptr = LDKAccess_init(env, clz, o);
4532         return tag_ptr(res_ptr, true);
4533 }
4534 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) {
4535         void* this_arg_ptr = untag_ptr(this_arg);
4536         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4537         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4538         unsigned char genesis_hash_arr[32];
4539         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4540         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4541         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4542         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4543         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4544         return tag_ptr(ret_conv, true);
4545 }
4546
4547 static jclass LDKCOption_AccessZ_Some_class = NULL;
4548 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
4549 static jclass LDKCOption_AccessZ_None_class = NULL;
4550 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
4551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4552         LDKCOption_AccessZ_Some_class =
4553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4554         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4555         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4556         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4557         LDKCOption_AccessZ_None_class =
4558                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4559         CHECK(LDKCOption_AccessZ_None_class != NULL);
4560         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4561         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4562 }
4563 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4564         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
4565         switch(obj->tag) {
4566                 case LDKCOption_AccessZ_Some: {
4567                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4568                         *some_ret = obj->some;
4569                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4570                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4571                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4572                                 LDKAccess_JCalls_cloned(&(*some_ret));
4573                         }
4574                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, tag_ptr(some_ret, true));
4575                 }
4576                 case LDKCOption_AccessZ_None: {
4577                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4578                 }
4579                 default: abort();
4580         }
4581 }
4582 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4583 CHECK(owner->result_ok);
4584         return *owner->contents.result;
4585 }
4586 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4587         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4588         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4589         return ret_conv;
4590 }
4591
4592 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4593         LDKLightningError ret = *owner->contents.err;
4594         ret.is_owned = false;
4595         return ret;
4596 }
4597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4598         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4599         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4600         int64_t ret_ref = 0;
4601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4603         return ret_ref;
4604 }
4605
4606 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4607         LDKChannelAnnouncement ret = owner->a;
4608         ret.is_owned = false;
4609         return ret;
4610 }
4611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4612         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4613         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4614         int64_t ret_ref = 0;
4615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4616         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4617         return ret_ref;
4618 }
4619
4620 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4621         LDKChannelUpdate ret = owner->b;
4622         ret.is_owned = false;
4623         return ret;
4624 }
4625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4626         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4627         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4628         int64_t ret_ref = 0;
4629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4631         return ret_ref;
4632 }
4633
4634 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4635         LDKChannelUpdate ret = owner->c;
4636         ret.is_owned = false;
4637         return ret;
4638 }
4639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4640         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4641         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4642         int64_t ret_ref = 0;
4643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4645         return ret_ref;
4646 }
4647
4648 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
4649 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
4650 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
4651 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
4652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
4653         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
4654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
4655         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
4656         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
4657         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
4658         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
4659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
4660         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
4661         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
4662         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
4663 }
4664 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4665         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4666         switch(obj->tag) {
4667                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
4668                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4669                         *some_conv = obj->some;
4670                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
4671                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
4672                 }
4673                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
4674                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
4675                 }
4676                 default: abort();
4677         }
4678 }
4679 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4680 CHECK(owner->result_ok);
4681         return *owner->contents.result;
4682 }
4683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4684         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4685         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4686 }
4687
4688 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4689         LDKLightningError ret = *owner->contents.err;
4690         ret.is_owned = false;
4691         return ret;
4692 }
4693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4694         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4695         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4696         int64_t ret_ref = 0;
4697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4698         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4699         return ret_ref;
4700 }
4701
4702 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4703         LDKChannelUpdateInfo ret = *owner->contents.result;
4704         ret.is_owned = false;
4705         return ret;
4706 }
4707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4708         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4709         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4710         int64_t ret_ref = 0;
4711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4712         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4713         return ret_ref;
4714 }
4715
4716 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4717 CHECK(!owner->result_ok);
4718         return DecodeError_clone(&*owner->contents.err);
4719 }
4720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4721         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4722         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4723         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4724         int64_t ret_ref = tag_ptr(ret_copy, true);
4725         return ret_ref;
4726 }
4727
4728 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4729         LDKChannelInfo ret = *owner->contents.result;
4730         ret.is_owned = false;
4731         return ret;
4732 }
4733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4734         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4735         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4736         int64_t ret_ref = 0;
4737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4738         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4739         return ret_ref;
4740 }
4741
4742 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4743 CHECK(!owner->result_ok);
4744         return DecodeError_clone(&*owner->contents.err);
4745 }
4746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4747         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4748         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4749         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4750         int64_t ret_ref = tag_ptr(ret_copy, true);
4751         return ret_ref;
4752 }
4753
4754 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4755         LDKRoutingFees ret = *owner->contents.result;
4756         ret.is_owned = false;
4757         return ret;
4758 }
4759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4760         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4761         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4762         int64_t ret_ref = 0;
4763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4765         return ret_ref;
4766 }
4767
4768 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4769 CHECK(!owner->result_ok);
4770         return DecodeError_clone(&*owner->contents.err);
4771 }
4772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4773         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4774         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4775         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4776         int64_t ret_ref = tag_ptr(ret_copy, true);
4777         return ret_ref;
4778 }
4779
4780 static jclass LDKNetAddress_IPv4_class = NULL;
4781 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4782 static jclass LDKNetAddress_IPv6_class = NULL;
4783 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4784 static jclass LDKNetAddress_OnionV2_class = NULL;
4785 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4786 static jclass LDKNetAddress_OnionV3_class = NULL;
4787 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4788 static jclass LDKNetAddress_Hostname_class = NULL;
4789 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4791         LDKNetAddress_IPv4_class =
4792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4793         CHECK(LDKNetAddress_IPv4_class != NULL);
4794         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4795         CHECK(LDKNetAddress_IPv4_meth != NULL);
4796         LDKNetAddress_IPv6_class =
4797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4798         CHECK(LDKNetAddress_IPv6_class != NULL);
4799         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4800         CHECK(LDKNetAddress_IPv6_meth != NULL);
4801         LDKNetAddress_OnionV2_class =
4802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4803         CHECK(LDKNetAddress_OnionV2_class != NULL);
4804         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4805         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4806         LDKNetAddress_OnionV3_class =
4807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4808         CHECK(LDKNetAddress_OnionV3_class != NULL);
4809         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4810         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4811         LDKNetAddress_Hostname_class =
4812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4813         CHECK(LDKNetAddress_Hostname_class != NULL);
4814         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4815         CHECK(LDKNetAddress_Hostname_meth != NULL);
4816 }
4817 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4818         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
4819         switch(obj->tag) {
4820                 case LDKNetAddress_IPv4: {
4821                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4822                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4823                         int16_t port_conv = obj->i_pv4.port;
4824                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4825                 }
4826                 case LDKNetAddress_IPv6: {
4827                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4828                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4829                         int16_t port_conv = obj->i_pv6.port;
4830                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4831                 }
4832                 case LDKNetAddress_OnionV2: {
4833                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4834                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4835                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4836                 }
4837                 case LDKNetAddress_OnionV3: {
4838                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4839                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4840                         int16_t checksum_conv = obj->onion_v3.checksum;
4841                         int8_t version_conv = obj->onion_v3.version;
4842                         int16_t port_conv = obj->onion_v3.port;
4843                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4844                 }
4845                 case LDKNetAddress_Hostname: {
4846                         LDKHostname hostname_var = obj->hostname.hostname;
4847                         int64_t hostname_ref = 0;
4848                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4849                         hostname_ref = tag_ptr(hostname_var.inner, false);
4850                         int16_t port_conv = obj->hostname.port;
4851                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4852                 }
4853                 default: abort();
4854         }
4855 }
4856 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4857         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4858         for (size_t i = 0; i < ret.datalen; i++) {
4859                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4860         }
4861         return ret;
4862 }
4863 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4864         LDKNodeAnnouncementInfo ret = *owner->contents.result;
4865         ret.is_owned = false;
4866         return ret;
4867 }
4868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4869         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4870         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4871         int64_t ret_ref = 0;
4872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4873         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4874         return ret_ref;
4875 }
4876
4877 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4878 CHECK(!owner->result_ok);
4879         return DecodeError_clone(&*owner->contents.err);
4880 }
4881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4882         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4883         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4884         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4885         int64_t ret_ref = tag_ptr(ret_copy, true);
4886         return ret_ref;
4887 }
4888
4889 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4890         LDKNodeAlias ret = *owner->contents.result;
4891         ret.is_owned = false;
4892         return ret;
4893 }
4894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4895         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4896         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4897         int64_t ret_ref = 0;
4898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4899         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4900         return ret_ref;
4901 }
4902
4903 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4904 CHECK(!owner->result_ok);
4905         return DecodeError_clone(&*owner->contents.err);
4906 }
4907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4908         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4909         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4910         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4911         int64_t ret_ref = tag_ptr(ret_copy, true);
4912         return ret_ref;
4913 }
4914
4915 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4916         LDKNodeInfo ret = *owner->contents.result;
4917         ret.is_owned = false;
4918         return ret;
4919 }
4920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4921         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4922         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4923         int64_t ret_ref = 0;
4924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4926         return ret_ref;
4927 }
4928
4929 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4930 CHECK(!owner->result_ok);
4931         return DecodeError_clone(&*owner->contents.err);
4932 }
4933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4934         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4935         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4936         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4937         int64_t ret_ref = tag_ptr(ret_copy, true);
4938         return ret_ref;
4939 }
4940
4941 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4942         LDKNetworkGraph ret = *owner->contents.result;
4943         ret.is_owned = false;
4944         return ret;
4945 }
4946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4947         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4948         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4949         int64_t ret_ref = 0;
4950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4952         return ret_ref;
4953 }
4954
4955 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4956 CHECK(!owner->result_ok);
4957         return DecodeError_clone(&*owner->contents.err);
4958 }
4959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4960         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4961         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4962         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4963         int64_t ret_ref = tag_ptr(ret_copy, true);
4964         return ret_ref;
4965 }
4966
4967 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4968 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4969 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4970 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4972         LDKCOption_CVec_NetAddressZZ_Some_class =
4973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4974         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4975         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4976         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4977         LDKCOption_CVec_NetAddressZZ_None_class =
4978                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4979         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4980         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4981         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4982 }
4983 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4984         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
4985         switch(obj->tag) {
4986                 case LDKCOption_CVec_NetAddressZZ_Some: {
4987                         LDKCVec_NetAddressZ some_var = obj->some;
4988                         int64_tArray some_arr = NULL;
4989                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4990                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4991                         for (size_t m = 0; m < some_var.datalen; m++) {
4992                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
4993                                 some_arr_ptr[m] = some_conv_12_ref;
4994                         }
4995                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4996                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4997                 }
4998                 case LDKCOption_CVec_NetAddressZZ_None: {
4999                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
5000                 }
5001                 default: abort();
5002         }
5003 }
5004 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5005         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
5006         ret.is_owned = false;
5007         return ret;
5008 }
5009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5010         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5011         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5012         int64_t ret_ref = 0;
5013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5015         return ret_ref;
5016 }
5017
5018 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5019 CHECK(!owner->result_ok);
5020         return DecodeError_clone(&*owner->contents.err);
5021 }
5022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5023         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5024         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5025         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5026         int64_t ret_ref = tag_ptr(ret_copy, true);
5027         return ret_ref;
5028 }
5029
5030 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5031         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
5032         ret.is_owned = false;
5033         return ret;
5034 }
5035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5036         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5037         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5038         int64_t ret_ref = 0;
5039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5041         return ret_ref;
5042 }
5043
5044 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5045 CHECK(!owner->result_ok);
5046         return DecodeError_clone(&*owner->contents.err);
5047 }
5048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5049         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5050         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5051         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5052         int64_t ret_ref = tag_ptr(ret_copy, true);
5053         return ret_ref;
5054 }
5055
5056 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5057 CHECK(owner->result_ok);
5058         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5059 }
5060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5061         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5062         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5063         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5064         int64_t ret_ref = tag_ptr(ret_copy, true);
5065         return ret_ref;
5066 }
5067
5068 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5069 CHECK(!owner->result_ok);
5070         return DecodeError_clone(&*owner->contents.err);
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5073         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5074         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5075         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5076         int64_t ret_ref = tag_ptr(ret_copy, true);
5077         return ret_ref;
5078 }
5079
5080 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
5081         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
5082         for (size_t i = 0; i < ret.datalen; i++) {
5083                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5084         }
5085         return ret;
5086 }
5087 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5088         return owner->a;
5089 }
5090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5091         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5092         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5093         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
5094         return ret_arr;
5095 }
5096
5097 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5098         return owner->b;
5099 }
5100 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5101         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5102         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
5103         jobjectArray ret_arr = NULL;
5104         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5105         ;
5106         for (size_t i = 0; i < ret_var.datalen; i++) {
5107                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
5108                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
5109                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5110         }
5111         
5112         return ret_arr;
5113 }
5114
5115 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5116 CHECK(owner->result_ok);
5117         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
5118 }
5119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5120         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5121         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5122         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
5123         return tag_ptr(ret_conv, true);
5124 }
5125
5126 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5127 CHECK(!owner->result_ok);
5128         return *owner->contents.err;
5129 }
5130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5131         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5132         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5133 }
5134
5135 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5136 CHECK(owner->result_ok);
5137         return *owner->contents.result;
5138 }
5139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5140         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5141         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5143         return ret_arr;
5144 }
5145
5146 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5147 CHECK(!owner->result_ok);
5148         return *owner->contents.err;
5149 }
5150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5151         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5152         CResult_SignatureNoneZ_get_err(owner_conv);
5153 }
5154
5155 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5156         return owner->a;
5157 }
5158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5159         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5160         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5161         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
5162         return ret_arr;
5163 }
5164
5165 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5166         return owner->b;
5167 }
5168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5169         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5170         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5171         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
5172         return ret_arr;
5173 }
5174
5175 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5176 CHECK(owner->result_ok);
5177         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
5178 }
5179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5180         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5181         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
5182         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
5183         return tag_ptr(ret_conv, true);
5184 }
5185
5186 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5187 CHECK(!owner->result_ok);
5188         return *owner->contents.err;
5189 }
5190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5191         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5192         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
5193 }
5194
5195 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5196 CHECK(owner->result_ok);
5197         return *owner->contents.result;
5198 }
5199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5200         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
5203         return ret_arr;
5204 }
5205
5206 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5207 CHECK(!owner->result_ok);
5208         return *owner->contents.err;
5209 }
5210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5211         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5212         CResult_SecretKeyNoneZ_get_err(owner_conv);
5213 }
5214
5215 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5216 CHECK(owner->result_ok);
5217         return *owner->contents.result;
5218 }
5219 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5220         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5221         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form);
5223         return ret_arr;
5224 }
5225
5226 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5227 CHECK(!owner->result_ok);
5228         return *owner->contents.err;
5229 }
5230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5231         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5232         CResult_PublicKeyNoneZ_get_err(owner_conv);
5233 }
5234
5235 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5236 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5237 static jclass LDKCOption_ScalarZ_None_class = NULL;
5238 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5240         LDKCOption_ScalarZ_Some_class =
5241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5242         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5243         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5244         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5245         LDKCOption_ScalarZ_None_class =
5246                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5247         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5248         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5249         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5250 }
5251 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5252         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5253         switch(obj->tag) {
5254                 case LDKCOption_ScalarZ_Some: {
5255                         LDKBigEndianScalar* some_ref = &obj->some;
5256                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5257                 }
5258                 case LDKCOption_ScalarZ_None: {
5259                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5260                 }
5261                 default: abort();
5262         }
5263 }
5264 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5265 CHECK(owner->result_ok);
5266         return ThirtyTwoBytes_clone(&*owner->contents.result);
5267 }
5268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5269         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5270         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5271         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5272         return ret_arr;
5273 }
5274
5275 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5276 CHECK(!owner->result_ok);
5277         return *owner->contents.err;
5278 }
5279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5280         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5281         CResult_SharedSecretNoneZ_get_err(owner_conv);
5282 }
5283
5284 typedef struct LDKBaseSign_JCalls {
5285         atomic_size_t refcnt;
5286         JavaVM *vm;
5287         jweak o;
5288         jmethodID get_per_commitment_point_meth;
5289         jmethodID release_commitment_secret_meth;
5290         jmethodID validate_holder_commitment_meth;
5291         jmethodID channel_keys_id_meth;
5292         jmethodID sign_counterparty_commitment_meth;
5293         jmethodID validate_counterparty_revocation_meth;
5294         jmethodID sign_holder_commitment_and_htlcs_meth;
5295         jmethodID sign_justice_revoked_output_meth;
5296         jmethodID sign_justice_revoked_htlc_meth;
5297         jmethodID sign_counterparty_htlc_transaction_meth;
5298         jmethodID sign_closing_transaction_meth;
5299         jmethodID sign_holder_anchor_input_meth;
5300         jmethodID sign_channel_announcement_meth;
5301         jmethodID provide_channel_parameters_meth;
5302 } LDKBaseSign_JCalls;
5303 static void LDKBaseSign_JCalls_free(void* this_arg) {
5304         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5305         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5306                 JNIEnv *env;
5307                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5308                 if (get_jenv_res == JNI_EDETACHED) {
5309                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5310                 } else {
5311                         DO_ASSERT(get_jenv_res == JNI_OK);
5312                 }
5313                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5314                 if (get_jenv_res == JNI_EDETACHED) {
5315                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5316                 }
5317                 FREE(j_calls);
5318         }
5319 }
5320 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5321         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5322         JNIEnv *env;
5323         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5324         if (get_jenv_res == JNI_EDETACHED) {
5325                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5326         } else {
5327                 DO_ASSERT(get_jenv_res == JNI_OK);
5328         }
5329         int64_t idx_conv = idx;
5330         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5331         CHECK(obj != NULL);
5332         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5333         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5334                 (*env)->ExceptionDescribe(env);
5335                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
5336         }
5337         LDKPublicKey ret_ref;
5338         CHECK((*env)->GetArrayLength(env, ret) == 33);
5339         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5340         if (get_jenv_res == JNI_EDETACHED) {
5341                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5342         }
5343         return ret_ref;
5344 }
5345 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5346         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5347         JNIEnv *env;
5348         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5349         if (get_jenv_res == JNI_EDETACHED) {
5350                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5351         } else {
5352                 DO_ASSERT(get_jenv_res == JNI_OK);
5353         }
5354         int64_t idx_conv = idx;
5355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5356         CHECK(obj != NULL);
5357         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5358         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5359                 (*env)->ExceptionDescribe(env);
5360                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
5361         }
5362         LDKThirtyTwoBytes ret_ref;
5363         CHECK((*env)->GetArrayLength(env, ret) == 32);
5364         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5365         if (get_jenv_res == JNI_EDETACHED) {
5366                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5367         }
5368         return ret_ref;
5369 }
5370 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5371         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5372         JNIEnv *env;
5373         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5374         if (get_jenv_res == JNI_EDETACHED) {
5375                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5376         } else {
5377                 DO_ASSERT(get_jenv_res == JNI_OK);
5378         }
5379         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5380         int64_t holder_tx_ref = 0;
5381         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5382         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5383         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5384         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5385         jobjectArray preimages_arr = NULL;
5386         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5387         ;
5388         for (size_t i = 0; i < preimages_var.datalen; i++) {
5389                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5390                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5391                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5392         }
5393         
5394         FREE(preimages_var.data);
5395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5396         CHECK(obj != NULL);
5397         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5398         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5399                 (*env)->ExceptionDescribe(env);
5400                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
5401         }
5402         void* ret_ptr = untag_ptr(ret);
5403         CHECK_ACCESS(ret_ptr);
5404         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5405         FREE(untag_ptr(ret));
5406         if (get_jenv_res == JNI_EDETACHED) {
5407                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5408         }
5409         return ret_conv;
5410 }
5411 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
5412         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5413         JNIEnv *env;
5414         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5415         if (get_jenv_res == JNI_EDETACHED) {
5416                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5417         } else {
5418                 DO_ASSERT(get_jenv_res == JNI_OK);
5419         }
5420         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5421         CHECK(obj != NULL);
5422         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5423         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5424                 (*env)->ExceptionDescribe(env);
5425                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
5426         }
5427         LDKThirtyTwoBytes ret_ref;
5428         CHECK((*env)->GetArrayLength(env, ret) == 32);
5429         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5430         if (get_jenv_res == JNI_EDETACHED) {
5431                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5432         }
5433         return ret_ref;
5434 }
5435 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
5436         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5437         JNIEnv *env;
5438         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5439         if (get_jenv_res == JNI_EDETACHED) {
5440                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5441         } else {
5442                 DO_ASSERT(get_jenv_res == JNI_OK);
5443         }
5444         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
5445         int64_t commitment_tx_ref = 0;
5446         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
5447         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5448         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5449         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5450         jobjectArray preimages_arr = NULL;
5451         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5452         ;
5453         for (size_t i = 0; i < preimages_var.datalen; i++) {
5454                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5455                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5456                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5457         }
5458         
5459         FREE(preimages_var.data);
5460         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5461         CHECK(obj != NULL);
5462         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
5463         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5464                 (*env)->ExceptionDescribe(env);
5465                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
5466         }
5467         void* ret_ptr = untag_ptr(ret);
5468         CHECK_ACCESS(ret_ptr);
5469         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5470         FREE(untag_ptr(ret));
5471         if (get_jenv_res == JNI_EDETACHED) {
5472                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5473         }
5474         return ret_conv;
5475 }
5476 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
5477         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5478         JNIEnv *env;
5479         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5480         if (get_jenv_res == JNI_EDETACHED) {
5481                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5482         } else {
5483                 DO_ASSERT(get_jenv_res == JNI_OK);
5484         }
5485         int64_t idx_conv = idx;
5486         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
5487         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
5488         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5489         CHECK(obj != NULL);
5490         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
5491         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5492                 (*env)->ExceptionDescribe(env);
5493                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
5494         }
5495         void* ret_ptr = untag_ptr(ret);
5496         CHECK_ACCESS(ret_ptr);
5497         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5498         FREE(untag_ptr(ret));
5499         if (get_jenv_res == JNI_EDETACHED) {
5500                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5501         }
5502         return ret_conv;
5503 }
5504 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
5505         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5506         JNIEnv *env;
5507         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5508         if (get_jenv_res == JNI_EDETACHED) {
5509                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5510         } else {
5511                 DO_ASSERT(get_jenv_res == JNI_OK);
5512         }
5513         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
5514         int64_t commitment_tx_ref = 0;
5515         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
5516         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5517         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5518         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5519         CHECK(obj != NULL);
5520         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5521         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5522                 (*env)->ExceptionDescribe(env);
5523                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5524         }
5525         void* ret_ptr = untag_ptr(ret);
5526         CHECK_ACCESS(ret_ptr);
5527         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5528         FREE(untag_ptr(ret));
5529         if (get_jenv_res == JNI_EDETACHED) {
5530                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5531         }
5532         return ret_conv;
5533 }
5534 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]) {
5535         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5536         JNIEnv *env;
5537         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5538         if (get_jenv_res == JNI_EDETACHED) {
5539                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5540         } else {
5541                 DO_ASSERT(get_jenv_res == JNI_OK);
5542         }
5543         LDKTransaction justice_tx_var = justice_tx;
5544         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5545         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5546         Transaction_free(justice_tx_var);
5547         int64_t input_conv = input;
5548         int64_t amount_conv = amount;
5549         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5550         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5551         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5552         CHECK(obj != NULL);
5553         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);
5554         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5555                 (*env)->ExceptionDescribe(env);
5556                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5557         }
5558         void* ret_ptr = untag_ptr(ret);
5559         CHECK_ACCESS(ret_ptr);
5560         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5561         FREE(untag_ptr(ret));
5562         if (get_jenv_res == JNI_EDETACHED) {
5563                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5564         }
5565         return ret_conv;
5566 }
5567 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) {
5568         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5569         JNIEnv *env;
5570         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5571         if (get_jenv_res == JNI_EDETACHED) {
5572                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5573         } else {
5574                 DO_ASSERT(get_jenv_res == JNI_OK);
5575         }
5576         LDKTransaction justice_tx_var = justice_tx;
5577         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5578         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5579         Transaction_free(justice_tx_var);
5580         int64_t input_conv = input;
5581         int64_t amount_conv = amount;
5582         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5583         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5584         LDKHTLCOutputInCommitment htlc_var = *htlc;
5585         int64_t htlc_ref = 0;
5586         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5587         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5588         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5589         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5590         CHECK(obj != NULL);
5591         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);
5592         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5593                 (*env)->ExceptionDescribe(env);
5594                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5595         }
5596         void* ret_ptr = untag_ptr(ret);
5597         CHECK_ACCESS(ret_ptr);
5598         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5599         FREE(untag_ptr(ret));
5600         if (get_jenv_res == JNI_EDETACHED) {
5601                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5602         }
5603         return ret_conv;
5604 }
5605 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) {
5606         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5607         JNIEnv *env;
5608         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5609         if (get_jenv_res == JNI_EDETACHED) {
5610                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5611         } else {
5612                 DO_ASSERT(get_jenv_res == JNI_OK);
5613         }
5614         LDKTransaction htlc_tx_var = htlc_tx;
5615         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5616         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5617         Transaction_free(htlc_tx_var);
5618         int64_t input_conv = input;
5619         int64_t amount_conv = amount;
5620         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5621         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5622         LDKHTLCOutputInCommitment htlc_var = *htlc;
5623         int64_t htlc_ref = 0;
5624         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5625         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5626         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5627         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5628         CHECK(obj != NULL);
5629         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);
5630         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5631                 (*env)->ExceptionDescribe(env);
5632                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5633         }
5634         void* ret_ptr = untag_ptr(ret);
5635         CHECK_ACCESS(ret_ptr);
5636         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5637         FREE(untag_ptr(ret));
5638         if (get_jenv_res == JNI_EDETACHED) {
5639                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5640         }
5641         return ret_conv;
5642 }
5643 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5644         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5645         JNIEnv *env;
5646         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5647         if (get_jenv_res == JNI_EDETACHED) {
5648                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5649         } else {
5650                 DO_ASSERT(get_jenv_res == JNI_OK);
5651         }
5652         LDKClosingTransaction closing_tx_var = *closing_tx;
5653         int64_t closing_tx_ref = 0;
5654         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5655         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5656         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
5657         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5658         CHECK(obj != NULL);
5659         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5660         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5661                 (*env)->ExceptionDescribe(env);
5662                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5663         }
5664         void* ret_ptr = untag_ptr(ret);
5665         CHECK_ACCESS(ret_ptr);
5666         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5667         FREE(untag_ptr(ret));
5668         if (get_jenv_res == JNI_EDETACHED) {
5669                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5670         }
5671         return ret_conv;
5672 }
5673 LDKCResult_SignatureNoneZ sign_holder_anchor_input_LDKBaseSign_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
5674         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5675         JNIEnv *env;
5676         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5677         if (get_jenv_res == JNI_EDETACHED) {
5678                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5679         } else {
5680                 DO_ASSERT(get_jenv_res == JNI_OK);
5681         }
5682         LDKTransaction anchor_tx_var = anchor_tx;
5683         int8_tArray anchor_tx_arr = (*env)->NewByteArray(env, anchor_tx_var.datalen);
5684         (*env)->SetByteArrayRegion(env, anchor_tx_arr, 0, anchor_tx_var.datalen, anchor_tx_var.data);
5685         Transaction_free(anchor_tx_var);
5686         int64_t input_conv = input;
5687         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5688         CHECK(obj != NULL);
5689         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_anchor_input_meth, anchor_tx_arr, input_conv);
5690         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5691                 (*env)->ExceptionDescribe(env);
5692                 (*env)->FatalError(env, "A call to sign_holder_anchor_input in LDKBaseSign from rust threw an exception.");
5693         }
5694         void* ret_ptr = untag_ptr(ret);
5695         CHECK_ACCESS(ret_ptr);
5696         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5697         FREE(untag_ptr(ret));
5698         if (get_jenv_res == JNI_EDETACHED) {
5699                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5700         }
5701         return ret_conv;
5702 }
5703 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5704         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5705         JNIEnv *env;
5706         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5707         if (get_jenv_res == JNI_EDETACHED) {
5708                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5709         } else {
5710                 DO_ASSERT(get_jenv_res == JNI_OK);
5711         }
5712         LDKUnsignedChannelAnnouncement msg_var = *msg;
5713         int64_t msg_ref = 0;
5714         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5715         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5716         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
5717         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5718         CHECK(obj != NULL);
5719         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5720         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5721                 (*env)->ExceptionDescribe(env);
5722                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5723         }
5724         void* ret_ptr = untag_ptr(ret);
5725         CHECK_ACCESS(ret_ptr);
5726         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5727         FREE(untag_ptr(ret));
5728         if (get_jenv_res == JNI_EDETACHED) {
5729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5730         }
5731         return ret_conv;
5732 }
5733 void provide_channel_parameters_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5734         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5735         JNIEnv *env;
5736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5737         if (get_jenv_res == JNI_EDETACHED) {
5738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5739         } else {
5740                 DO_ASSERT(get_jenv_res == JNI_OK);
5741         }
5742         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5743         int64_t channel_parameters_ref = 0;
5744         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5745         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5746         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5747         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5748         CHECK(obj != NULL);
5749         (*env)->CallVoidMethod(env, obj, j_calls->provide_channel_parameters_meth, channel_parameters_ref);
5750         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5751                 (*env)->ExceptionDescribe(env);
5752                 (*env)->FatalError(env, "A call to provide_channel_parameters in LDKBaseSign from rust threw an exception.");
5753         }
5754         if (get_jenv_res == JNI_EDETACHED) {
5755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5756         }
5757 }
5758 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5759         jclass c = (*env)->GetObjectClass(env, o);
5760         CHECK(c != NULL);
5761         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5762         atomic_init(&calls->refcnt, 1);
5763         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5764         calls->o = (*env)->NewWeakGlobalRef(env, o);
5765         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5766         CHECK(calls->get_per_commitment_point_meth != NULL);
5767         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5768         CHECK(calls->release_commitment_secret_meth != NULL);
5769         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5770         CHECK(calls->validate_holder_commitment_meth != NULL);
5771         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5772         CHECK(calls->channel_keys_id_meth != NULL);
5773         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5774         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5775         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5776         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5777         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5778         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5779         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5780         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5781         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5782         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5783         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5784         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5785         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5786         CHECK(calls->sign_closing_transaction_meth != NULL);
5787         calls->sign_holder_anchor_input_meth = (*env)->GetMethodID(env, c, "sign_holder_anchor_input", "([BJ)J");
5788         CHECK(calls->sign_holder_anchor_input_meth != NULL);
5789         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5790         CHECK(calls->sign_channel_announcement_meth != NULL);
5791         calls->provide_channel_parameters_meth = (*env)->GetMethodID(env, c, "provide_channel_parameters", "(J)V");
5792         CHECK(calls->provide_channel_parameters_meth != NULL);
5793
5794         LDKChannelPublicKeys pubkeys_conv;
5795         pubkeys_conv.inner = untag_ptr(pubkeys);
5796         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5797         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5798
5799         LDKBaseSign ret = {
5800                 .this_arg = (void*) calls,
5801                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5802                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5803                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5804                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5805                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5806                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5807                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5808                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5809                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5810                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5811                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5812                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKBaseSign_jcall,
5813                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5814                 .provide_channel_parameters = provide_channel_parameters_LDKBaseSign_jcall,
5815                 .free = LDKBaseSign_JCalls_free,
5816                 .pubkeys = pubkeys_conv,
5817                 .set_pubkeys = NULL,
5818         };
5819         return ret;
5820 }
5821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5822         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5823         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5824         return tag_ptr(res_ptr, true);
5825 }
5826 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) {
5827         void* this_arg_ptr = untag_ptr(this_arg);
5828         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5829         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5830         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5832         return ret_arr;
5833 }
5834
5835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5836         void* this_arg_ptr = untag_ptr(this_arg);
5837         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5838         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5841         return ret_arr;
5842 }
5843
5844 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) {
5845         void* this_arg_ptr = untag_ptr(this_arg);
5846         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5847         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5848         LDKHolderCommitmentTransaction holder_tx_conv;
5849         holder_tx_conv.inner = untag_ptr(holder_tx);
5850         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
5851         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5852         holder_tx_conv.is_owned = false;
5853         LDKCVec_PaymentPreimageZ preimages_constr;
5854         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5855         if (preimages_constr.datalen > 0)
5856                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5857         else
5858                 preimages_constr.data = NULL;
5859         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5860                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5861                 LDKThirtyTwoBytes preimages_conv_8_ref;
5862                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5863                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5864                 preimages_constr.data[i] = preimages_conv_8_ref;
5865         }
5866         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5867         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5868         return tag_ptr(ret_conv, true);
5869 }
5870
5871 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5872         void* this_arg_ptr = untag_ptr(this_arg);
5873         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5874         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5877         return ret_arr;
5878 }
5879
5880 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) {
5881         void* this_arg_ptr = untag_ptr(this_arg);
5882         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5883         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5884         LDKCommitmentTransaction commitment_tx_conv;
5885         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5886         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5887         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5888         commitment_tx_conv.is_owned = false;
5889         LDKCVec_PaymentPreimageZ preimages_constr;
5890         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5891         if (preimages_constr.datalen > 0)
5892                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5893         else
5894                 preimages_constr.data = NULL;
5895         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5896                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5897                 LDKThirtyTwoBytes preimages_conv_8_ref;
5898                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5899                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5900                 preimages_constr.data[i] = preimages_conv_8_ref;
5901         }
5902         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5903         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5904         return tag_ptr(ret_conv, true);
5905 }
5906
5907 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) {
5908         void* this_arg_ptr = untag_ptr(this_arg);
5909         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5910         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5911         unsigned char secret_arr[32];
5912         CHECK((*env)->GetArrayLength(env, secret) == 32);
5913         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5914         unsigned char (*secret_ref)[32] = &secret_arr;
5915         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5916         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5917         return tag_ptr(ret_conv, true);
5918 }
5919
5920 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) {
5921         void* this_arg_ptr = untag_ptr(this_arg);
5922         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5923         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5924         LDKHolderCommitmentTransaction commitment_tx_conv;
5925         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5926         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5927         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5928         commitment_tx_conv.is_owned = false;
5929         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5930         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5931         return tag_ptr(ret_conv, true);
5932 }
5933
5934 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) {
5935         void* this_arg_ptr = untag_ptr(this_arg);
5936         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5937         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5938         LDKTransaction justice_tx_ref;
5939         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5940         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5941         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5942         justice_tx_ref.data_is_owned = true;
5943         unsigned char per_commitment_key_arr[32];
5944         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5945         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5946         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5947         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5948         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5949         return tag_ptr(ret_conv, true);
5950 }
5951
5952 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) {
5953         void* this_arg_ptr = untag_ptr(this_arg);
5954         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5955         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5956         LDKTransaction justice_tx_ref;
5957         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5958         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5959         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5960         justice_tx_ref.data_is_owned = true;
5961         unsigned char per_commitment_key_arr[32];
5962         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5963         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5964         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5965         LDKHTLCOutputInCommitment htlc_conv;
5966         htlc_conv.inner = untag_ptr(htlc);
5967         htlc_conv.is_owned = ptr_is_owned(htlc);
5968         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5969         htlc_conv.is_owned = false;
5970         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5971         *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);
5972         return tag_ptr(ret_conv, true);
5973 }
5974
5975 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) {
5976         void* this_arg_ptr = untag_ptr(this_arg);
5977         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5978         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5979         LDKTransaction htlc_tx_ref;
5980         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5981         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5982         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5983         htlc_tx_ref.data_is_owned = true;
5984         LDKPublicKey per_commitment_point_ref;
5985         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5986         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5987         LDKHTLCOutputInCommitment htlc_conv;
5988         htlc_conv.inner = untag_ptr(htlc);
5989         htlc_conv.is_owned = ptr_is_owned(htlc);
5990         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5991         htlc_conv.is_owned = false;
5992         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5993         *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);
5994         return tag_ptr(ret_conv, true);
5995 }
5996
5997 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) {
5998         void* this_arg_ptr = untag_ptr(this_arg);
5999         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6000         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6001         LDKClosingTransaction closing_tx_conv;
6002         closing_tx_conv.inner = untag_ptr(closing_tx);
6003         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
6004         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
6005         closing_tx_conv.is_owned = false;
6006         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6007         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
6008         return tag_ptr(ret_conv, true);
6009 }
6010
6011 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) {
6012         void* this_arg_ptr = untag_ptr(this_arg);
6013         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6014         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6015         LDKTransaction anchor_tx_ref;
6016         anchor_tx_ref.datalen = (*env)->GetArrayLength(env, anchor_tx);
6017         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
6018         (*env)->GetByteArrayRegion(env, anchor_tx, 0, anchor_tx_ref.datalen, anchor_tx_ref.data);
6019         anchor_tx_ref.data_is_owned = true;
6020         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6021         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
6022         return tag_ptr(ret_conv, true);
6023 }
6024
6025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6026         void* this_arg_ptr = untag_ptr(this_arg);
6027         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6028         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6029         LDKUnsignedChannelAnnouncement msg_conv;
6030         msg_conv.inner = untag_ptr(msg);
6031         msg_conv.is_owned = ptr_is_owned(msg);
6032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6033         msg_conv.is_owned = false;
6034         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
6035         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6036         return tag_ptr(ret_conv, true);
6037 }
6038
6039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1provide_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
6040         void* this_arg_ptr = untag_ptr(this_arg);
6041         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6042         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6043         LDKChannelTransactionParameters channel_parameters_conv;
6044         channel_parameters_conv.inner = untag_ptr(channel_parameters);
6045         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
6046         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
6047         channel_parameters_conv.is_owned = false;
6048         (this_arg_conv->provide_channel_parameters)(this_arg_conv->this_arg, &channel_parameters_conv);
6049 }
6050
6051 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
6052         if (this_arg->set_pubkeys != NULL)
6053                 this_arg->set_pubkeys(this_arg);
6054         return this_arg->pubkeys;
6055 }
6056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
6057         void* this_arg_ptr = untag_ptr(this_arg);
6058         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6059         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6060         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
6061         int64_t ret_ref = 0;
6062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6063         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6064         return ret_ref;
6065 }
6066
6067 typedef struct LDKSign_JCalls {
6068         atomic_size_t refcnt;
6069         JavaVM *vm;
6070         jweak o;
6071         LDKBaseSign_JCalls* BaseSign;
6072         jmethodID write_meth;
6073 } LDKSign_JCalls;
6074 static void LDKSign_JCalls_free(void* this_arg) {
6075         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
6076         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6077                 JNIEnv *env;
6078                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6079                 if (get_jenv_res == JNI_EDETACHED) {
6080                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6081                 } else {
6082                         DO_ASSERT(get_jenv_res == JNI_OK);
6083                 }
6084                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6085                 if (get_jenv_res == JNI_EDETACHED) {
6086                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6087                 }
6088                 FREE(j_calls);
6089         }
6090 }
6091 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
6092         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
6093         JNIEnv *env;
6094         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6095         if (get_jenv_res == JNI_EDETACHED) {
6096                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6097         } else {
6098                 DO_ASSERT(get_jenv_res == JNI_OK);
6099         }
6100         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6101         CHECK(obj != NULL);
6102         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6103         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6104                 (*env)->ExceptionDescribe(env);
6105                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
6106         }
6107         LDKCVec_u8Z ret_ref;
6108         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6109         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6110         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6111         if (get_jenv_res == JNI_EDETACHED) {
6112                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6113         }
6114         return ret_ref;
6115 }
6116 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
6117         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
6118         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6119         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
6120 }
6121 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
6122         jclass c = (*env)->GetObjectClass(env, o);
6123         CHECK(c != NULL);
6124         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
6125         atomic_init(&calls->refcnt, 1);
6126         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6127         calls->o = (*env)->NewWeakGlobalRef(env, o);
6128         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6129         CHECK(calls->write_meth != NULL);
6130
6131         LDKChannelPublicKeys pubkeys_conv;
6132         pubkeys_conv.inner = untag_ptr(pubkeys);
6133         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6134         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6135
6136         LDKSign ret = {
6137                 .this_arg = (void*) calls,
6138                 .write = write_LDKSign_jcall,
6139                 .cloned = LDKSign_JCalls_cloned,
6140                 .free = LDKSign_JCalls_free,
6141                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
6142         };
6143         calls->BaseSign = ret.BaseSign.this_arg;
6144         return ret;
6145 }
6146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
6147         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
6148         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
6149         return tag_ptr(res_ptr, true);
6150 }
6151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
6152         LDKSign *inp = (LDKSign *)untag_ptr(arg);
6153         return tag_ptr(&inp->BaseSign, false);
6154 }
6155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6156         void* this_arg_ptr = untag_ptr(this_arg);
6157         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6158         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
6159         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6162         CVec_u8Z_free(ret_var);
6163         return ret_arr;
6164 }
6165
6166 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6167 CHECK(owner->result_ok);
6168         return Sign_clone(&*owner->contents.result);
6169 }
6170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6171         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6172         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6173         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
6174         return tag_ptr(ret_ret, true);
6175 }
6176
6177 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6178 CHECK(!owner->result_ok);
6179         return DecodeError_clone(&*owner->contents.err);
6180 }
6181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6182         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6183         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6184         *ret_copy = CResult_SignDecodeErrorZ_get_err(owner_conv);
6185         int64_t ret_ref = tag_ptr(ret_copy, true);
6186         return ret_ref;
6187 }
6188
6189 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6190 CHECK(owner->result_ok);
6191         return *owner->contents.result;
6192 }
6193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6194         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6195         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
6196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
6197         return ret_arr;
6198 }
6199
6200 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6201 CHECK(!owner->result_ok);
6202         return *owner->contents.err;
6203 }
6204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6205         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6206         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
6207 }
6208
6209 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6210         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6211         for (size_t i = 0; i < ret.datalen; i++) {
6212                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6213         }
6214         return ret;
6215 }
6216 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6217 CHECK(owner->result_ok);
6218         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6219 }
6220 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6221         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6222         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6223         jobjectArray ret_arr = NULL;
6224         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6225         ;
6226         for (size_t i = 0; i < ret_var.datalen; i++) {
6227                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6228                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6229                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6230                 CVec_u8Z_free(ret_conv_8_var);
6231                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6232         }
6233         
6234         FREE(ret_var.data);
6235         return ret_arr;
6236 }
6237
6238 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6239 CHECK(!owner->result_ok);
6240         return *owner->contents.err;
6241 }
6242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6243         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6244         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6245 }
6246
6247 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6248         LDKInMemorySigner ret = *owner->contents.result;
6249         ret.is_owned = false;
6250         return ret;
6251 }
6252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6253         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6254         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6255         int64_t ret_ref = 0;
6256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6258         return ret_ref;
6259 }
6260
6261 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6262 CHECK(!owner->result_ok);
6263         return DecodeError_clone(&*owner->contents.err);
6264 }
6265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6266         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6267         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6268         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6269         int64_t ret_ref = tag_ptr(ret_copy, true);
6270         return ret_ref;
6271 }
6272
6273 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6274         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6275         for (size_t i = 0; i < ret.datalen; i++) {
6276                 ret.data[i] = TxOut_clone(&orig->data[i]);
6277         }
6278         return ret;
6279 }
6280 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6281 CHECK(owner->result_ok);
6282         return *owner->contents.result;
6283 }
6284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6285         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6286         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6287         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6288         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6289         return ret_arr;
6290 }
6291
6292 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6293 CHECK(!owner->result_ok);
6294         return *owner->contents.err;
6295 }
6296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6297         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6298         CResult_TransactionNoneZ_get_err(owner_conv);
6299 }
6300
6301 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6302         return ThirtyTwoBytes_clone(&owner->a);
6303 }
6304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6305         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6306         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6307         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6308         return ret_arr;
6309 }
6310
6311 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6312         LDKChannelMonitor ret = owner->b;
6313         ret.is_owned = false;
6314         return ret;
6315 }
6316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6317         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6318         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6319         int64_t ret_ref = 0;
6320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6322         return ret_ref;
6323 }
6324
6325 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6326         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6327         for (size_t i = 0; i < ret.datalen; i++) {
6328                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6329         }
6330         return ret;
6331 }
6332 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6333 CHECK(owner->result_ok);
6334         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6335 }
6336 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6337         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6338         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6339         int64_tArray ret_arr = NULL;
6340         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6341         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6342         for (size_t j = 0; j < ret_var.datalen; j++) {
6343                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6344                 *ret_conv_35_conv = ret_var.data[j];
6345                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6346         }
6347         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6348         FREE(ret_var.data);
6349         return ret_arr;
6350 }
6351
6352 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6353 CHECK(!owner->result_ok);
6354         return *owner->contents.err;
6355 }
6356 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6357         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6358         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6359         return ret_conv;
6360 }
6361
6362 static jclass LDKCOption_u16Z_Some_class = NULL;
6363 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6364 static jclass LDKCOption_u16Z_None_class = NULL;
6365 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6367         LDKCOption_u16Z_Some_class =
6368                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6369         CHECK(LDKCOption_u16Z_Some_class != NULL);
6370         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6371         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6372         LDKCOption_u16Z_None_class =
6373                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6374         CHECK(LDKCOption_u16Z_None_class != NULL);
6375         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6376         CHECK(LDKCOption_u16Z_None_meth != NULL);
6377 }
6378 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6379         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6380         switch(obj->tag) {
6381                 case LDKCOption_u16Z_Some: {
6382                         int16_t some_conv = obj->some;
6383                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6384                 }
6385                 case LDKCOption_u16Z_None: {
6386                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6387                 }
6388                 default: abort();
6389         }
6390 }
6391 static jclass LDKAPIError_APIMisuseError_class = NULL;
6392 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
6393 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
6394 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
6395 static jclass LDKAPIError_InvalidRoute_class = NULL;
6396 static jmethodID LDKAPIError_InvalidRoute_meth = NULL;
6397 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
6398 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
6399 static jclass LDKAPIError_MonitorUpdateInProgress_class = NULL;
6400 static jmethodID LDKAPIError_MonitorUpdateInProgress_meth = NULL;
6401 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
6402 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
6403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
6404         LDKAPIError_APIMisuseError_class =
6405                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
6406         CHECK(LDKAPIError_APIMisuseError_class != NULL);
6407         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
6408         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
6409         LDKAPIError_FeeRateTooHigh_class =
6410                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
6411         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
6412         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
6413         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
6414         LDKAPIError_InvalidRoute_class =
6415                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$InvalidRoute"));
6416         CHECK(LDKAPIError_InvalidRoute_class != NULL);
6417         LDKAPIError_InvalidRoute_meth = (*env)->GetMethodID(env, LDKAPIError_InvalidRoute_class, "<init>", "(Ljava/lang/String;)V");
6418         CHECK(LDKAPIError_InvalidRoute_meth != NULL);
6419         LDKAPIError_ChannelUnavailable_class =
6420                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
6421         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
6422         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
6423         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
6424         LDKAPIError_MonitorUpdateInProgress_class =
6425                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateInProgress"));
6426         CHECK(LDKAPIError_MonitorUpdateInProgress_class != NULL);
6427         LDKAPIError_MonitorUpdateInProgress_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateInProgress_class, "<init>", "()V");
6428         CHECK(LDKAPIError_MonitorUpdateInProgress_meth != NULL);
6429         LDKAPIError_IncompatibleShutdownScript_class =
6430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
6431         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
6432         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
6433         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
6434 }
6435 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6436         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
6437         switch(obj->tag) {
6438                 case LDKAPIError_APIMisuseError: {
6439                         LDKStr err_str = obj->api_misuse_error.err;
6440                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6441                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
6442                 }
6443                 case LDKAPIError_FeeRateTooHigh: {
6444                         LDKStr err_str = obj->fee_rate_too_high.err;
6445                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6446                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
6447                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
6448                 }
6449                 case LDKAPIError_InvalidRoute: {
6450                         LDKStr err_str = obj->invalid_route.err;
6451                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6452                         return (*env)->NewObject(env, LDKAPIError_InvalidRoute_class, LDKAPIError_InvalidRoute_meth, err_conv);
6453                 }
6454                 case LDKAPIError_ChannelUnavailable: {
6455                         LDKStr err_str = obj->channel_unavailable.err;
6456                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6457                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
6458                 }
6459                 case LDKAPIError_MonitorUpdateInProgress: {
6460                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateInProgress_class, LDKAPIError_MonitorUpdateInProgress_meth);
6461                 }
6462                 case LDKAPIError_IncompatibleShutdownScript: {
6463                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
6464                         int64_t script_ref = 0;
6465                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
6466                         script_ref = tag_ptr(script_var.inner, false);
6467                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
6468                 }
6469                 default: abort();
6470         }
6471 }
6472 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6473 CHECK(owner->result_ok);
6474         return *owner->contents.result;
6475 }
6476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6477         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6478         CResult_NoneAPIErrorZ_get_ok(owner_conv);
6479 }
6480
6481 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6482 CHECK(!owner->result_ok);
6483         return APIError_clone(&*owner->contents.err);
6484 }
6485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6486         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6487         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6488         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
6489         int64_t ret_ref = tag_ptr(ret_copy, true);
6490         return ret_ref;
6491 }
6492
6493 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
6494         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
6495         for (size_t i = 0; i < ret.datalen; i++) {
6496                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
6497         }
6498         return ret;
6499 }
6500 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
6501         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
6502         for (size_t i = 0; i < ret.datalen; i++) {
6503                 ret.data[i] = APIError_clone(&orig->data[i]);
6504         }
6505         return ret;
6506 }
6507 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6508 CHECK(owner->result_ok);
6509         return ThirtyTwoBytes_clone(&*owner->contents.result);
6510 }
6511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6512         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6513         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6514         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6515         return ret_arr;
6516 }
6517
6518 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6519 CHECK(!owner->result_ok);
6520         return APIError_clone(&*owner->contents.err);
6521 }
6522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6523         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6524         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6525         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6526         int64_t ret_ref = tag_ptr(ret_copy, true);
6527         return ret_ref;
6528 }
6529
6530 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6531 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6532 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6533 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6534 static jclass LDKPaymentSendFailure_AllFailedResendSafe_class = NULL;
6535 static jmethodID LDKPaymentSendFailure_AllFailedResendSafe_meth = NULL;
6536 static jclass LDKPaymentSendFailure_DuplicatePayment_class = NULL;
6537 static jmethodID LDKPaymentSendFailure_DuplicatePayment_meth = NULL;
6538 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6539 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6541         LDKPaymentSendFailure_ParameterError_class =
6542                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6543         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6544         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6545         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6546         LDKPaymentSendFailure_PathParameterError_class =
6547                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6548         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6549         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6550         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6551         LDKPaymentSendFailure_AllFailedResendSafe_class =
6552                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedResendSafe"));
6553         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_class != NULL);
6554         LDKPaymentSendFailure_AllFailedResendSafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedResendSafe_class, "<init>", "([J)V");
6555         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_meth != NULL);
6556         LDKPaymentSendFailure_DuplicatePayment_class =
6557                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$DuplicatePayment"));
6558         CHECK(LDKPaymentSendFailure_DuplicatePayment_class != NULL);
6559         LDKPaymentSendFailure_DuplicatePayment_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_DuplicatePayment_class, "<init>", "()V");
6560         CHECK(LDKPaymentSendFailure_DuplicatePayment_meth != NULL);
6561         LDKPaymentSendFailure_PartialFailure_class =
6562                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6563         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6564         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6565         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6566 }
6567 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6568         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
6569         switch(obj->tag) {
6570                 case LDKPaymentSendFailure_ParameterError: {
6571                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
6572                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6573                 }
6574                 case LDKPaymentSendFailure_PathParameterError: {
6575                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6576                         int64_tArray path_parameter_error_arr = NULL;
6577                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6578                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6579                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6580                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6581                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6582                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6583                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
6584                         }
6585                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6586                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6587                 }
6588                 case LDKPaymentSendFailure_AllFailedResendSafe: {
6589                         LDKCVec_APIErrorZ all_failed_resend_safe_var = obj->all_failed_resend_safe;
6590                         int64_tArray all_failed_resend_safe_arr = NULL;
6591                         all_failed_resend_safe_arr = (*env)->NewLongArray(env, all_failed_resend_safe_var.datalen);
6592                         int64_t *all_failed_resend_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_resend_safe_arr, NULL);
6593                         for (size_t k = 0; k < all_failed_resend_safe_var.datalen; k++) {
6594                                 int64_t all_failed_resend_safe_conv_10_ref = tag_ptr(&all_failed_resend_safe_var.data[k], false);
6595                                 all_failed_resend_safe_arr_ptr[k] = all_failed_resend_safe_conv_10_ref;
6596                         }
6597                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_resend_safe_arr, all_failed_resend_safe_arr_ptr, 0);
6598                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedResendSafe_class, LDKPaymentSendFailure_AllFailedResendSafe_meth, all_failed_resend_safe_arr);
6599                 }
6600                 case LDKPaymentSendFailure_DuplicatePayment: {
6601                         return (*env)->NewObject(env, LDKPaymentSendFailure_DuplicatePayment_class, LDKPaymentSendFailure_DuplicatePayment_meth);
6602                 }
6603                 case LDKPaymentSendFailure_PartialFailure: {
6604                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6605                         int64_tArray results_arr = NULL;
6606                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6607                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6608                         for (size_t w = 0; w < results_var.datalen; w++) {
6609                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6610                                 *results_conv_22_conv = results_var.data[w];
6611                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6612                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
6613                         }
6614                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6615                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6616                         int64_t failed_paths_retry_ref = 0;
6617                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6618                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
6619                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6620                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6621                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6622                 }
6623                 default: abort();
6624         }
6625 }
6626 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6627 CHECK(owner->result_ok);
6628         return *owner->contents.result;
6629 }
6630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6631         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6632         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6633 }
6634
6635 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6636 CHECK(!owner->result_ok);
6637         return PaymentSendFailure_clone(&*owner->contents.err);
6638 }
6639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6640         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6641         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6642         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6643         int64_t ret_ref = tag_ptr(ret_copy, true);
6644         return ret_ref;
6645 }
6646
6647 static inline struct LDKThirtyTwoBytes CResult_PaymentHashPaymentSendFailureZ_get_ok(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
6648 CHECK(owner->result_ok);
6649         return ThirtyTwoBytes_clone(&*owner->contents.result);
6650 }
6651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6652         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
6653         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6654         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashPaymentSendFailureZ_get_ok(owner_conv).data);
6655         return ret_arr;
6656 }
6657
6658 static inline struct LDKPaymentSendFailure CResult_PaymentHashPaymentSendFailureZ_get_err(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
6659 CHECK(!owner->result_ok);
6660         return PaymentSendFailure_clone(&*owner->contents.err);
6661 }
6662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6663         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
6664         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6665         *ret_copy = CResult_PaymentHashPaymentSendFailureZ_get_err(owner_conv);
6666         int64_t ret_ref = tag_ptr(ret_copy, true);
6667         return ret_ref;
6668 }
6669
6670 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6671         return ThirtyTwoBytes_clone(&owner->a);
6672 }
6673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6674         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6675         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6676         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6677         return ret_arr;
6678 }
6679
6680 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6681         return ThirtyTwoBytes_clone(&owner->b);
6682 }
6683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6684         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6685         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6686         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6687         return ret_arr;
6688 }
6689
6690 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6691 CHECK(owner->result_ok);
6692         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6693 }
6694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6695         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6696         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6697         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6698         return tag_ptr(ret_conv, true);
6699 }
6700
6701 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6702 CHECK(!owner->result_ok);
6703         return PaymentSendFailure_clone(&*owner->contents.err);
6704 }
6705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6706         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6707         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6708         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6709         int64_t ret_ref = tag_ptr(ret_copy, true);
6710         return ret_ref;
6711 }
6712
6713 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6714         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6715         for (size_t i = 0; i < ret.datalen; i++) {
6716                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6717         }
6718         return ret;
6719 }
6720 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6721         return ThirtyTwoBytes_clone(&owner->a);
6722 }
6723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6724         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6725         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6727         return ret_arr;
6728 }
6729
6730 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6731         return ThirtyTwoBytes_clone(&owner->b);
6732 }
6733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6734         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6735         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6737         return ret_arr;
6738 }
6739
6740 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6741 CHECK(owner->result_ok);
6742         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6743 }
6744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6745         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6746         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6747         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6748         return tag_ptr(ret_conv, true);
6749 }
6750
6751 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6752 CHECK(!owner->result_ok);
6753         return *owner->contents.err;
6754 }
6755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6756         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6757         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6758 }
6759
6760 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6761 CHECK(owner->result_ok);
6762         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6763 }
6764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6765         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6766         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6767         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6768         return tag_ptr(ret_conv, true);
6769 }
6770
6771 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6772 CHECK(!owner->result_ok);
6773         return APIError_clone(&*owner->contents.err);
6774 }
6775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6776         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6777         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6778         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6779         int64_t ret_ref = tag_ptr(ret_copy, true);
6780         return ret_ref;
6781 }
6782
6783 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6784 CHECK(owner->result_ok);
6785         return ThirtyTwoBytes_clone(&*owner->contents.result);
6786 }
6787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6788         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6789         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6791         return ret_arr;
6792 }
6793
6794 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6795 CHECK(!owner->result_ok);
6796         return *owner->contents.err;
6797 }
6798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6799         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6800         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6801 }
6802
6803 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6804 CHECK(owner->result_ok);
6805         return ThirtyTwoBytes_clone(&*owner->contents.result);
6806 }
6807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6808         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6811         return ret_arr;
6812 }
6813
6814 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6815 CHECK(!owner->result_ok);
6816         return APIError_clone(&*owner->contents.err);
6817 }
6818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6819         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6820         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6821         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6822         int64_t ret_ref = tag_ptr(ret_copy, true);
6823         return ret_ref;
6824 }
6825
6826 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6827 CHECK(owner->result_ok);
6828         return ThirtyTwoBytes_clone(&*owner->contents.result);
6829 }
6830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6831         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6832         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6833         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6834         return ret_arr;
6835 }
6836
6837 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6838 CHECK(!owner->result_ok);
6839         return APIError_clone(&*owner->contents.err);
6840 }
6841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6842         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6843         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6844         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6845         int64_t ret_ref = tag_ptr(ret_copy, true);
6846         return ret_ref;
6847 }
6848
6849 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6850         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
6851         ret.is_owned = false;
6852         return ret;
6853 }
6854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6855         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6856         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6857         int64_t ret_ref = 0;
6858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6860         return ret_ref;
6861 }
6862
6863 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6864 CHECK(!owner->result_ok);
6865         return DecodeError_clone(&*owner->contents.err);
6866 }
6867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6868         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6869         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6870         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6871         int64_t ret_ref = tag_ptr(ret_copy, true);
6872         return ret_ref;
6873 }
6874
6875 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6876         LDKChannelCounterparty ret = *owner->contents.result;
6877         ret.is_owned = false;
6878         return ret;
6879 }
6880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6881         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6882         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6883         int64_t ret_ref = 0;
6884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6886         return ret_ref;
6887 }
6888
6889 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6890 CHECK(!owner->result_ok);
6891         return DecodeError_clone(&*owner->contents.err);
6892 }
6893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6894         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6895         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6896         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6897         int64_t ret_ref = tag_ptr(ret_copy, true);
6898         return ret_ref;
6899 }
6900
6901 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6902         LDKChannelDetails ret = *owner->contents.result;
6903         ret.is_owned = false;
6904         return ret;
6905 }
6906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6907         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6908         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6909         int64_t ret_ref = 0;
6910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6912         return ret_ref;
6913 }
6914
6915 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6916 CHECK(!owner->result_ok);
6917         return DecodeError_clone(&*owner->contents.err);
6918 }
6919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6920         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6921         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6922         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6923         int64_t ret_ref = tag_ptr(ret_copy, true);
6924         return ret_ref;
6925 }
6926
6927 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6928         LDKPhantomRouteHints ret = *owner->contents.result;
6929         ret.is_owned = false;
6930         return ret;
6931 }
6932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6933         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6934         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6935         int64_t ret_ref = 0;
6936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6938         return ret_ref;
6939 }
6940
6941 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6942 CHECK(!owner->result_ok);
6943         return DecodeError_clone(&*owner->contents.err);
6944 }
6945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6946         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6947         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6948         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6949         int64_t ret_ref = tag_ptr(ret_copy, true);
6950         return ret_ref;
6951 }
6952
6953 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6954         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6955         for (size_t i = 0; i < ret.datalen; i++) {
6956                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6957         }
6958         return ret;
6959 }
6960 typedef struct LDKWatch_JCalls {
6961         atomic_size_t refcnt;
6962         JavaVM *vm;
6963         jweak o;
6964         jmethodID watch_channel_meth;
6965         jmethodID update_channel_meth;
6966         jmethodID release_pending_monitor_events_meth;
6967 } LDKWatch_JCalls;
6968 static void LDKWatch_JCalls_free(void* this_arg) {
6969         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6970         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6971                 JNIEnv *env;
6972                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6973                 if (get_jenv_res == JNI_EDETACHED) {
6974                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6975                 } else {
6976                         DO_ASSERT(get_jenv_res == JNI_OK);
6977                 }
6978                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6979                 if (get_jenv_res == JNI_EDETACHED) {
6980                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6981                 }
6982                 FREE(j_calls);
6983         }
6984 }
6985 LDKChannelMonitorUpdateStatus watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6986         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6987         JNIEnv *env;
6988         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6989         if (get_jenv_res == JNI_EDETACHED) {
6990                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6991         } else {
6992                 DO_ASSERT(get_jenv_res == JNI_OK);
6993         }
6994         LDKOutPoint funding_txo_var = funding_txo;
6995         int64_t funding_txo_ref = 0;
6996         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6997         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6998         LDKChannelMonitor monitor_var = monitor;
6999         int64_t monitor_ref = 0;
7000         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
7001         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
7002         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7003         CHECK(obj != NULL);
7004         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
7005         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7006                 (*env)->ExceptionDescribe(env);
7007                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
7008         }
7009         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7010         if (get_jenv_res == JNI_EDETACHED) {
7011                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7012         }
7013         return ret_conv;
7014 }
7015 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
7016         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7017         JNIEnv *env;
7018         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7019         if (get_jenv_res == JNI_EDETACHED) {
7020                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7021         } else {
7022                 DO_ASSERT(get_jenv_res == JNI_OK);
7023         }
7024         LDKOutPoint funding_txo_var = funding_txo;
7025         int64_t funding_txo_ref = 0;
7026         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7027         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7028         LDKChannelMonitorUpdate update_var = update;
7029         int64_t update_ref = 0;
7030         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7031         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
7032         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7033         CHECK(obj != NULL);
7034         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
7035         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7036                 (*env)->ExceptionDescribe(env);
7037                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
7038         }
7039         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7040         if (get_jenv_res == JNI_EDETACHED) {
7041                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7042         }
7043         return ret_conv;
7044 }
7045 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
7046         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7047         JNIEnv *env;
7048         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7049         if (get_jenv_res == JNI_EDETACHED) {
7050                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7051         } else {
7052                 DO_ASSERT(get_jenv_res == JNI_OK);
7053         }
7054         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7055         CHECK(obj != NULL);
7056         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
7057         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7058                 (*env)->ExceptionDescribe(env);
7059                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
7060         }
7061         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
7062         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7063         if (ret_constr.datalen > 0)
7064                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
7065         else
7066                 ret_constr.data = NULL;
7067         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7068         for (size_t x = 0; x < ret_constr.datalen; x++) {
7069                 int64_t ret_conv_49 = ret_vals[x];
7070                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
7071                 CHECK_ACCESS(ret_conv_49_ptr);
7072                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
7073                 FREE(untag_ptr(ret_conv_49));
7074                 ret_constr.data[x] = ret_conv_49_conv;
7075         }
7076         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7077         if (get_jenv_res == JNI_EDETACHED) {
7078                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7079         }
7080         return ret_constr;
7081 }
7082 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
7083         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
7084         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7085 }
7086 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
7087         jclass c = (*env)->GetObjectClass(env, o);
7088         CHECK(c != NULL);
7089         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
7090         atomic_init(&calls->refcnt, 1);
7091         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7092         calls->o = (*env)->NewWeakGlobalRef(env, o);
7093         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7094         CHECK(calls->watch_channel_meth != NULL);
7095         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7096         CHECK(calls->update_channel_meth != NULL);
7097         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
7098         CHECK(calls->release_pending_monitor_events_meth != NULL);
7099
7100         LDKWatch ret = {
7101                 .this_arg = (void*) calls,
7102                 .watch_channel = watch_channel_LDKWatch_jcall,
7103                 .update_channel = update_channel_LDKWatch_jcall,
7104                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
7105                 .free = LDKWatch_JCalls_free,
7106         };
7107         return ret;
7108 }
7109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
7110         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
7111         *res_ptr = LDKWatch_init(env, clz, o);
7112         return tag_ptr(res_ptr, true);
7113 }
7114 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) {
7115         void* this_arg_ptr = untag_ptr(this_arg);
7116         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7117         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7118         LDKOutPoint funding_txo_conv;
7119         funding_txo_conv.inner = untag_ptr(funding_txo);
7120         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7121         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7122         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7123         LDKChannelMonitor monitor_conv;
7124         monitor_conv.inner = untag_ptr(monitor);
7125         monitor_conv.is_owned = ptr_is_owned(monitor);
7126         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
7127         monitor_conv = ChannelMonitor_clone(&monitor_conv);
7128         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv));
7129         return ret_conv;
7130 }
7131
7132 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) {
7133         void* this_arg_ptr = untag_ptr(this_arg);
7134         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7135         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7136         LDKOutPoint funding_txo_conv;
7137         funding_txo_conv.inner = untag_ptr(funding_txo);
7138         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7139         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7140         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7141         LDKChannelMonitorUpdate update_conv;
7142         update_conv.inner = untag_ptr(update);
7143         update_conv.is_owned = ptr_is_owned(update);
7144         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7145         update_conv = ChannelMonitorUpdate_clone(&update_conv);
7146         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv));
7147         return ret_conv;
7148 }
7149
7150 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7151         void* this_arg_ptr = untag_ptr(this_arg);
7152         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7153         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7154         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
7155         int64_tArray ret_arr = NULL;
7156         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7157         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7158         for (size_t x = 0; x < ret_var.datalen; x++) {
7159                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
7160                 *ret_conv_49_conv = ret_var.data[x];
7161                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
7162         }
7163         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7164         FREE(ret_var.data);
7165         return ret_arr;
7166 }
7167
7168 typedef struct LDKBroadcasterInterface_JCalls {
7169         atomic_size_t refcnt;
7170         JavaVM *vm;
7171         jweak o;
7172         jmethodID broadcast_transaction_meth;
7173 } LDKBroadcasterInterface_JCalls;
7174 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7175         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7176         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7177                 JNIEnv *env;
7178                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7179                 if (get_jenv_res == JNI_EDETACHED) {
7180                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7181                 } else {
7182                         DO_ASSERT(get_jenv_res == JNI_OK);
7183                 }
7184                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7185                 if (get_jenv_res == JNI_EDETACHED) {
7186                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7187                 }
7188                 FREE(j_calls);
7189         }
7190 }
7191 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7192         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7193         JNIEnv *env;
7194         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7195         if (get_jenv_res == JNI_EDETACHED) {
7196                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7197         } else {
7198                 DO_ASSERT(get_jenv_res == JNI_OK);
7199         }
7200         LDKTransaction tx_var = tx;
7201         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7202         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7203         Transaction_free(tx_var);
7204         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7205         CHECK(obj != NULL);
7206         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7207         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7208                 (*env)->ExceptionDescribe(env);
7209                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7210         }
7211         if (get_jenv_res == JNI_EDETACHED) {
7212                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7213         }
7214 }
7215 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7216         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7217         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7218 }
7219 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7220         jclass c = (*env)->GetObjectClass(env, o);
7221         CHECK(c != NULL);
7222         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7223         atomic_init(&calls->refcnt, 1);
7224         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7225         calls->o = (*env)->NewWeakGlobalRef(env, o);
7226         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7227         CHECK(calls->broadcast_transaction_meth != NULL);
7228
7229         LDKBroadcasterInterface ret = {
7230                 .this_arg = (void*) calls,
7231                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7232                 .free = LDKBroadcasterInterface_JCalls_free,
7233         };
7234         return ret;
7235 }
7236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7237         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7238         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7239         return tag_ptr(res_ptr, true);
7240 }
7241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7242         void* this_arg_ptr = untag_ptr(this_arg);
7243         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7244         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7245         LDKTransaction tx_ref;
7246         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7247         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7248         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7249         tx_ref.data_is_owned = true;
7250         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7251 }
7252
7253 typedef struct LDKKeysInterface_JCalls {
7254         atomic_size_t refcnt;
7255         JavaVM *vm;
7256         jweak o;
7257         jmethodID get_node_secret_meth;
7258         jmethodID get_node_id_meth;
7259         jmethodID ecdh_meth;
7260         jmethodID get_destination_script_meth;
7261         jmethodID get_shutdown_scriptpubkey_meth;
7262         jmethodID generate_channel_keys_id_meth;
7263         jmethodID derive_channel_signer_meth;
7264         jmethodID get_secure_random_bytes_meth;
7265         jmethodID read_chan_signer_meth;
7266         jmethodID sign_invoice_meth;
7267         jmethodID get_inbound_payment_key_material_meth;
7268 } LDKKeysInterface_JCalls;
7269 static void LDKKeysInterface_JCalls_free(void* this_arg) {
7270         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7271         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7272                 JNIEnv *env;
7273                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7274                 if (get_jenv_res == JNI_EDETACHED) {
7275                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7276                 } else {
7277                         DO_ASSERT(get_jenv_res == JNI_OK);
7278                 }
7279                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7280                 if (get_jenv_res == JNI_EDETACHED) {
7281                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7282                 }
7283                 FREE(j_calls);
7284         }
7285 }
7286 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7287         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7288         JNIEnv *env;
7289         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7290         if (get_jenv_res == JNI_EDETACHED) {
7291                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7292         } else {
7293                 DO_ASSERT(get_jenv_res == JNI_OK);
7294         }
7295         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7296         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7297         CHECK(obj != NULL);
7298         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
7299         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7300                 (*env)->ExceptionDescribe(env);
7301                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
7302         }
7303         void* ret_ptr = untag_ptr(ret);
7304         CHECK_ACCESS(ret_ptr);
7305         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
7306         FREE(untag_ptr(ret));
7307         if (get_jenv_res == JNI_EDETACHED) {
7308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7309         }
7310         return ret_conv;
7311 }
7312 LDKCResult_PublicKeyNoneZ get_node_id_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7313         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7314         JNIEnv *env;
7315         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7316         if (get_jenv_res == JNI_EDETACHED) {
7317                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7318         } else {
7319                 DO_ASSERT(get_jenv_res == JNI_OK);
7320         }
7321         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7322         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7323         CHECK(obj != NULL);
7324         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_id_meth, recipient_conv);
7325         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7326                 (*env)->ExceptionDescribe(env);
7327                 (*env)->FatalError(env, "A call to get_node_id in LDKKeysInterface from rust threw an exception.");
7328         }
7329         void* ret_ptr = untag_ptr(ret);
7330         CHECK_ACCESS(ret_ptr);
7331         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
7332         FREE(untag_ptr(ret));
7333         if (get_jenv_res == JNI_EDETACHED) {
7334                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7335         }
7336         return ret_conv;
7337 }
7338 LDKCResult_SharedSecretNoneZ ecdh_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7339         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7340         JNIEnv *env;
7341         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7342         if (get_jenv_res == JNI_EDETACHED) {
7343                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7344         } else {
7345                 DO_ASSERT(get_jenv_res == JNI_OK);
7346         }
7347         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7348         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
7349         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
7350         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
7351         *tweak_copy = tweak;
7352         int64_t tweak_ref = tag_ptr(tweak_copy, true);
7353         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7354         CHECK(obj != NULL);
7355         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
7356         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7357                 (*env)->ExceptionDescribe(env);
7358                 (*env)->FatalError(env, "A call to ecdh in LDKKeysInterface from rust threw an exception.");
7359         }
7360         void* ret_ptr = untag_ptr(ret);
7361         CHECK_ACCESS(ret_ptr);
7362         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
7363         FREE(untag_ptr(ret));
7364         if (get_jenv_res == JNI_EDETACHED) {
7365                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7366         }
7367         return ret_conv;
7368 }
7369 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
7370         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7371         JNIEnv *env;
7372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7373         if (get_jenv_res == JNI_EDETACHED) {
7374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7375         } else {
7376                 DO_ASSERT(get_jenv_res == JNI_OK);
7377         }
7378         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7379         CHECK(obj != NULL);
7380         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
7381         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7382                 (*env)->ExceptionDescribe(env);
7383                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
7384         }
7385         LDKCVec_u8Z ret_ref;
7386         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7387         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7388         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7389         if (get_jenv_res == JNI_EDETACHED) {
7390                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7391         }
7392         return ret_ref;
7393 }
7394 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
7395         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7396         JNIEnv *env;
7397         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7398         if (get_jenv_res == JNI_EDETACHED) {
7399                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7400         } else {
7401                 DO_ASSERT(get_jenv_res == JNI_OK);
7402         }
7403         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7404         CHECK(obj != NULL);
7405         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
7406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7407                 (*env)->ExceptionDescribe(env);
7408                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
7409         }
7410         LDKShutdownScript ret_conv;
7411         ret_conv.inner = untag_ptr(ret);
7412         ret_conv.is_owned = ptr_is_owned(ret);
7413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
7414         if (get_jenv_res == JNI_EDETACHED) {
7415                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7416         }
7417         return ret_conv;
7418 }
7419 LDKThirtyTwoBytes generate_channel_keys_id_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis, LDKU128 user_channel_id) {
7420         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7421         JNIEnv *env;
7422         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7423         if (get_jenv_res == JNI_EDETACHED) {
7424                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7425         } else {
7426                 DO_ASSERT(get_jenv_res == JNI_OK);
7427         }
7428         jboolean inbound_conv = inbound;
7429         int64_t channel_value_satoshis_conv = channel_value_satoshis;
7430         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
7431         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, user_channel_id.le_bytes);
7432         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7433         CHECK(obj != NULL);
7434         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->generate_channel_keys_id_meth, inbound_conv, channel_value_satoshis_conv, user_channel_id_arr);
7435         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7436                 (*env)->ExceptionDescribe(env);
7437                 (*env)->FatalError(env, "A call to generate_channel_keys_id in LDKKeysInterface from rust threw an exception.");
7438         }
7439         LDKThirtyTwoBytes ret_ref;
7440         CHECK((*env)->GetArrayLength(env, ret) == 32);
7441         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7442         if (get_jenv_res == JNI_EDETACHED) {
7443                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7444         }
7445         return ret_ref;
7446 }
7447 LDKSign derive_channel_signer_LDKKeysInterface_jcall(const void* this_arg, uint64_t channel_value_satoshis, LDKThirtyTwoBytes channel_keys_id) {
7448         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7449         JNIEnv *env;
7450         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7451         if (get_jenv_res == JNI_EDETACHED) {
7452                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7453         } else {
7454                 DO_ASSERT(get_jenv_res == JNI_OK);
7455         }
7456         int64_t channel_value_satoshis_conv = channel_value_satoshis;
7457         int8_tArray channel_keys_id_arr = (*env)->NewByteArray(env, 32);
7458         (*env)->SetByteArrayRegion(env, channel_keys_id_arr, 0, 32, channel_keys_id.data);
7459         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7460         CHECK(obj != NULL);
7461         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->derive_channel_signer_meth, channel_value_satoshis_conv, channel_keys_id_arr);
7462         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7463                 (*env)->ExceptionDescribe(env);
7464                 (*env)->FatalError(env, "A call to derive_channel_signer in LDKKeysInterface from rust threw an exception.");
7465         }
7466         void* ret_ptr = untag_ptr(ret);
7467         CHECK_ACCESS(ret_ptr);
7468         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
7469         FREE(untag_ptr(ret));
7470         if (get_jenv_res == JNI_EDETACHED) {
7471                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7472         }
7473         return ret_conv;
7474 }
7475 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
7476         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7477         JNIEnv *env;
7478         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7479         if (get_jenv_res == JNI_EDETACHED) {
7480                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7481         } else {
7482                 DO_ASSERT(get_jenv_res == JNI_OK);
7483         }
7484         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7485         CHECK(obj != NULL);
7486         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7487         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7488                 (*env)->ExceptionDescribe(env);
7489                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
7490         }
7491         LDKThirtyTwoBytes ret_ref;
7492         CHECK((*env)->GetArrayLength(env, ret) == 32);
7493         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7494         if (get_jenv_res == JNI_EDETACHED) {
7495                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7496         }
7497         return ret_ref;
7498 }
7499 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
7500         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7501         JNIEnv *env;
7502         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7503         if (get_jenv_res == JNI_EDETACHED) {
7504                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7505         } else {
7506                 DO_ASSERT(get_jenv_res == JNI_OK);
7507         }
7508         LDKu8slice reader_var = reader;
7509         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
7510         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
7511         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7512         CHECK(obj != NULL);
7513         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
7514         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7515                 (*env)->ExceptionDescribe(env);
7516                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
7517         }
7518         void* ret_ptr = untag_ptr(ret);
7519         CHECK_ACCESS(ret_ptr);
7520         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
7521         FREE(untag_ptr(ret));
7522         if (get_jenv_res == JNI_EDETACHED) {
7523                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7524         }
7525         return ret_conv;
7526 }
7527 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_U5Z invoice_data, LDKRecipient receipient) {
7528         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7529         JNIEnv *env;
7530         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7531         if (get_jenv_res == JNI_EDETACHED) {
7532                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7533         } else {
7534                 DO_ASSERT(get_jenv_res == JNI_OK);
7535         }
7536         LDKu8slice hrp_bytes_var = hrp_bytes;
7537         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
7538         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7539         LDKCVec_U5Z invoice_data_var = invoice_data;
7540         jobjectArray invoice_data_arr = NULL;
7541         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7542         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7543         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7544                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7545                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7546         }
7547         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7548         FREE(invoice_data_var.data);
7549         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7551         CHECK(obj != NULL);
7552         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7553         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7554                 (*env)->ExceptionDescribe(env);
7555                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7556         }
7557         void* ret_ptr = untag_ptr(ret);
7558         CHECK_ACCESS(ret_ptr);
7559         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7560         FREE(untag_ptr(ret));
7561         if (get_jenv_res == JNI_EDETACHED) {
7562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7563         }
7564         return ret_conv;
7565 }
7566 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7567         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7568         JNIEnv *env;
7569         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7570         if (get_jenv_res == JNI_EDETACHED) {
7571                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7572         } else {
7573                 DO_ASSERT(get_jenv_res == JNI_OK);
7574         }
7575         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7576         CHECK(obj != NULL);
7577         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7578         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7579                 (*env)->ExceptionDescribe(env);
7580                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7581         }
7582         LDKThirtyTwoBytes ret_ref;
7583         CHECK((*env)->GetArrayLength(env, ret) == 32);
7584         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7585         if (get_jenv_res == JNI_EDETACHED) {
7586                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7587         }
7588         return ret_ref;
7589 }
7590 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7591         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7592         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7593 }
7594 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7595         jclass c = (*env)->GetObjectClass(env, o);
7596         CHECK(c != NULL);
7597         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7598         atomic_init(&calls->refcnt, 1);
7599         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7600         calls->o = (*env)->NewWeakGlobalRef(env, o);
7601         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7602         CHECK(calls->get_node_secret_meth != NULL);
7603         calls->get_node_id_meth = (*env)->GetMethodID(env, c, "get_node_id", "(Lorg/ldk/enums/Recipient;)J");
7604         CHECK(calls->get_node_id_meth != NULL);
7605         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
7606         CHECK(calls->ecdh_meth != NULL);
7607         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7608         CHECK(calls->get_destination_script_meth != NULL);
7609         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7610         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7611         calls->generate_channel_keys_id_meth = (*env)->GetMethodID(env, c, "generate_channel_keys_id", "(ZJ[B)[B");
7612         CHECK(calls->generate_channel_keys_id_meth != NULL);
7613         calls->derive_channel_signer_meth = (*env)->GetMethodID(env, c, "derive_channel_signer", "(J[B)J");
7614         CHECK(calls->derive_channel_signer_meth != NULL);
7615         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7616         CHECK(calls->get_secure_random_bytes_meth != NULL);
7617         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7618         CHECK(calls->read_chan_signer_meth != NULL);
7619         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7620         CHECK(calls->sign_invoice_meth != NULL);
7621         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7622         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7623
7624         LDKKeysInterface ret = {
7625                 .this_arg = (void*) calls,
7626                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7627                 .get_node_id = get_node_id_LDKKeysInterface_jcall,
7628                 .ecdh = ecdh_LDKKeysInterface_jcall,
7629                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7630                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7631                 .generate_channel_keys_id = generate_channel_keys_id_LDKKeysInterface_jcall,
7632                 .derive_channel_signer = derive_channel_signer_LDKKeysInterface_jcall,
7633                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7634                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7635                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7636                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7637                 .free = LDKKeysInterface_JCalls_free,
7638         };
7639         return ret;
7640 }
7641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7642         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7643         *res_ptr = LDKKeysInterface_init(env, clz, o);
7644         return tag_ptr(res_ptr, true);
7645 }
7646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7647         void* this_arg_ptr = untag_ptr(this_arg);
7648         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7649         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7650         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7651         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7652         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7653         return tag_ptr(ret_conv, true);
7654 }
7655
7656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7657         void* this_arg_ptr = untag_ptr(this_arg);
7658         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7659         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7660         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7661         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
7662         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
7663         return tag_ptr(ret_conv, true);
7664 }
7665
7666 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) {
7667         void* this_arg_ptr = untag_ptr(this_arg);
7668         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7669         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7670         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7671         LDKPublicKey other_key_ref;
7672         CHECK((*env)->GetArrayLength(env, other_key) == 33);
7673         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
7674         void* tweak_ptr = untag_ptr(tweak);
7675         CHECK_ACCESS(tweak_ptr);
7676         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
7677         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
7678         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
7679         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
7680         return tag_ptr(ret_conv, true);
7681 }
7682
7683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7684         void* this_arg_ptr = untag_ptr(this_arg);
7685         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7686         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7687         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7688         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7689         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7690         CVec_u8Z_free(ret_var);
7691         return ret_arr;
7692 }
7693
7694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7695         void* this_arg_ptr = untag_ptr(this_arg);
7696         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7697         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7698         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7699         int64_t ret_ref = 0;
7700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7701         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7702         return ret_ref;
7703 }
7704
7705 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) {
7706         void* this_arg_ptr = untag_ptr(this_arg);
7707         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7708         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7709         LDKU128 user_channel_id_ref;
7710         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
7711         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
7712         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7713         (*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);
7714         return ret_arr;
7715 }
7716
7717 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) {
7718         void* this_arg_ptr = untag_ptr(this_arg);
7719         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7720         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7721         LDKThirtyTwoBytes channel_keys_id_ref;
7722         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
7723         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
7724         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7725         *ret_ret = (this_arg_conv->derive_channel_signer)(this_arg_conv->this_arg, channel_value_satoshis, channel_keys_id_ref);
7726         return tag_ptr(ret_ret, true);
7727 }
7728
7729 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7730         void* this_arg_ptr = untag_ptr(this_arg);
7731         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7732         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7733         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7735         return ret_arr;
7736 }
7737
7738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7739         void* this_arg_ptr = untag_ptr(this_arg);
7740         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7741         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7742         LDKu8slice reader_ref;
7743         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7744         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7745         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7746         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7747         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7748         return tag_ptr(ret_conv, true);
7749 }
7750
7751 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) {
7752         void* this_arg_ptr = untag_ptr(this_arg);
7753         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7754         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7755         LDKu8slice hrp_bytes_ref;
7756         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7757         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7758         LDKCVec_U5Z invoice_data_constr;
7759         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7760         if (invoice_data_constr.datalen > 0)
7761                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
7762         else
7763                 invoice_data_constr.data = NULL;
7764         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7765         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7766                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7767                 
7768                 invoice_data_constr.data[h] = (LDKU5){ ._0 = invoice_data_conv_7 };
7769         }
7770         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7771         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7772         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7773         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7774         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7775         return tag_ptr(ret_conv, true);
7776 }
7777
7778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7779         void* this_arg_ptr = untag_ptr(this_arg);
7780         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7781         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7782         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7784         return ret_arr;
7785 }
7786
7787 typedef struct LDKFeeEstimator_JCalls {
7788         atomic_size_t refcnt;
7789         JavaVM *vm;
7790         jweak o;
7791         jmethodID get_est_sat_per_1000_weight_meth;
7792 } LDKFeeEstimator_JCalls;
7793 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7794         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7795         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7796                 JNIEnv *env;
7797                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7798                 if (get_jenv_res == JNI_EDETACHED) {
7799                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7800                 } else {
7801                         DO_ASSERT(get_jenv_res == JNI_OK);
7802                 }
7803                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7804                 if (get_jenv_res == JNI_EDETACHED) {
7805                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7806                 }
7807                 FREE(j_calls);
7808         }
7809 }
7810 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7811         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7812         JNIEnv *env;
7813         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7814         if (get_jenv_res == JNI_EDETACHED) {
7815                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7816         } else {
7817                 DO_ASSERT(get_jenv_res == JNI_OK);
7818         }
7819         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7820         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7821         CHECK(obj != NULL);
7822         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7823         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7824                 (*env)->ExceptionDescribe(env);
7825                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7826         }
7827         if (get_jenv_res == JNI_EDETACHED) {
7828                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7829         }
7830         return ret;
7831 }
7832 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7833         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7834         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7835 }
7836 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7837         jclass c = (*env)->GetObjectClass(env, o);
7838         CHECK(c != NULL);
7839         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7840         atomic_init(&calls->refcnt, 1);
7841         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7842         calls->o = (*env)->NewWeakGlobalRef(env, o);
7843         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7844         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7845
7846         LDKFeeEstimator ret = {
7847                 .this_arg = (void*) calls,
7848                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7849                 .free = LDKFeeEstimator_JCalls_free,
7850         };
7851         return ret;
7852 }
7853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7854         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7855         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7856         return tag_ptr(res_ptr, true);
7857 }
7858 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) {
7859         void* this_arg_ptr = untag_ptr(this_arg);
7860         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7861         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7862         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7863         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7864         return ret_conv;
7865 }
7866
7867 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7868         return ThirtyTwoBytes_clone(&owner->a);
7869 }
7870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7871         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7872         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7874         return ret_arr;
7875 }
7876
7877 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7878         LDKChannelManager ret = owner->b;
7879         ret.is_owned = false;
7880         return ret;
7881 }
7882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7883         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7884         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7885         int64_t ret_ref = 0;
7886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7888         return ret_ref;
7889 }
7890
7891 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7892 CHECK(owner->result_ok);
7893         return &*owner->contents.result;
7894 }
7895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7896         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7897         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
7898         return ret_ret;
7899 }
7900
7901 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7902 CHECK(!owner->result_ok);
7903         return DecodeError_clone(&*owner->contents.err);
7904 }
7905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7906         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7907         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7908         *ret_copy = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7909         int64_t ret_ref = tag_ptr(ret_copy, true);
7910         return ret_ref;
7911 }
7912
7913 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7914         LDKChannelConfig ret = *owner->contents.result;
7915         ret.is_owned = false;
7916         return ret;
7917 }
7918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7919         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7920         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7921         int64_t ret_ref = 0;
7922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7924         return ret_ref;
7925 }
7926
7927 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7928 CHECK(!owner->result_ok);
7929         return DecodeError_clone(&*owner->contents.err);
7930 }
7931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7932         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7933         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7934         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7935         int64_t ret_ref = tag_ptr(ret_copy, true);
7936         return ret_ref;
7937 }
7938
7939 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7940         LDKOutPoint ret = *owner->contents.result;
7941         ret.is_owned = false;
7942         return ret;
7943 }
7944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7945         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7946         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7947         int64_t ret_ref = 0;
7948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7949         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7950         return ret_ref;
7951 }
7952
7953 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7954 CHECK(!owner->result_ok);
7955         return DecodeError_clone(&*owner->contents.err);
7956 }
7957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7958         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7959         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7960         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7961         int64_t ret_ref = tag_ptr(ret_copy, true);
7962         return ret_ref;
7963 }
7964
7965 typedef struct LDKType_JCalls {
7966         atomic_size_t refcnt;
7967         JavaVM *vm;
7968         jweak o;
7969         jmethodID type_id_meth;
7970         jmethodID debug_str_meth;
7971         jmethodID write_meth;
7972 } LDKType_JCalls;
7973 static void LDKType_JCalls_free(void* this_arg) {
7974         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7975         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7976                 JNIEnv *env;
7977                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7978                 if (get_jenv_res == JNI_EDETACHED) {
7979                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7980                 } else {
7981                         DO_ASSERT(get_jenv_res == JNI_OK);
7982                 }
7983                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7984                 if (get_jenv_res == JNI_EDETACHED) {
7985                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7986                 }
7987                 FREE(j_calls);
7988         }
7989 }
7990 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7991         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7992         JNIEnv *env;
7993         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7994         if (get_jenv_res == JNI_EDETACHED) {
7995                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7996         } else {
7997                 DO_ASSERT(get_jenv_res == JNI_OK);
7998         }
7999         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8000         CHECK(obj != NULL);
8001         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
8002         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8003                 (*env)->ExceptionDescribe(env);
8004                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
8005         }
8006         if (get_jenv_res == JNI_EDETACHED) {
8007                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8008         }
8009         return ret;
8010 }
8011 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
8012         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8013         JNIEnv *env;
8014         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8015         if (get_jenv_res == JNI_EDETACHED) {
8016                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8017         } else {
8018                 DO_ASSERT(get_jenv_res == JNI_OK);
8019         }
8020         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8021         CHECK(obj != NULL);
8022         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
8023         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8024                 (*env)->ExceptionDescribe(env);
8025                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
8026         }
8027         LDKStr ret_conv = java_to_owned_str(env, ret);
8028         if (get_jenv_res == JNI_EDETACHED) {
8029                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8030         }
8031         return ret_conv;
8032 }
8033 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
8034         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8035         JNIEnv *env;
8036         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8037         if (get_jenv_res == JNI_EDETACHED) {
8038                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8039         } else {
8040                 DO_ASSERT(get_jenv_res == JNI_OK);
8041         }
8042         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8043         CHECK(obj != NULL);
8044         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
8045         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8046                 (*env)->ExceptionDescribe(env);
8047                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
8048         }
8049         LDKCVec_u8Z ret_ref;
8050         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8051         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8052         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8053         if (get_jenv_res == JNI_EDETACHED) {
8054                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8055         }
8056         return ret_ref;
8057 }
8058 static void LDKType_JCalls_cloned(LDKType* new_obj) {
8059         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
8060         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8061 }
8062 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
8063         jclass c = (*env)->GetObjectClass(env, o);
8064         CHECK(c != NULL);
8065         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
8066         atomic_init(&calls->refcnt, 1);
8067         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8068         calls->o = (*env)->NewWeakGlobalRef(env, o);
8069         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
8070         CHECK(calls->type_id_meth != NULL);
8071         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
8072         CHECK(calls->debug_str_meth != NULL);
8073         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
8074         CHECK(calls->write_meth != NULL);
8075
8076         LDKType ret = {
8077                 .this_arg = (void*) calls,
8078                 .type_id = type_id_LDKType_jcall,
8079                 .debug_str = debug_str_LDKType_jcall,
8080                 .write = write_LDKType_jcall,
8081                 .cloned = LDKType_JCalls_cloned,
8082                 .free = LDKType_JCalls_free,
8083         };
8084         return ret;
8085 }
8086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
8087         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
8088         *res_ptr = LDKType_init(env, clz, o);
8089         return tag_ptr(res_ptr, true);
8090 }
8091 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
8092         void* this_arg_ptr = untag_ptr(this_arg);
8093         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8094         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8095         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
8096         return ret_conv;
8097 }
8098
8099 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
8100         void* this_arg_ptr = untag_ptr(this_arg);
8101         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8102         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8103         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
8104         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8105         Str_free(ret_str);
8106         return ret_conv;
8107 }
8108
8109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
8110         void* this_arg_ptr = untag_ptr(this_arg);
8111         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8112         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8113         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8114         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8115         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8116         CVec_u8Z_free(ret_var);
8117         return ret_arr;
8118 }
8119
8120 static jclass LDKCOption_TypeZ_Some_class = NULL;
8121 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
8122 static jclass LDKCOption_TypeZ_None_class = NULL;
8123 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
8124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
8125         LDKCOption_TypeZ_Some_class =
8126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
8127         CHECK(LDKCOption_TypeZ_Some_class != NULL);
8128         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
8129         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
8130         LDKCOption_TypeZ_None_class =
8131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
8132         CHECK(LDKCOption_TypeZ_None_class != NULL);
8133         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
8134         CHECK(LDKCOption_TypeZ_None_meth != NULL);
8135 }
8136 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8137         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
8138         switch(obj->tag) {
8139                 case LDKCOption_TypeZ_Some: {
8140                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
8141                         *some_ret = Type_clone(&obj->some);
8142                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
8143                 }
8144                 case LDKCOption_TypeZ_None: {
8145                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
8146                 }
8147                 default: abort();
8148         }
8149 }
8150 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
8151 CHECK(owner->result_ok);
8152         return COption_TypeZ_clone(&*owner->contents.result);
8153 }
8154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8155         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
8156         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
8157         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
8158         int64_t ret_ref = tag_ptr(ret_copy, true);
8159         return ret_ref;
8160 }
8161
8162 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
8163 CHECK(!owner->result_ok);
8164         return DecodeError_clone(&*owner->contents.err);
8165 }
8166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8167         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
8168         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8169         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
8170         int64_t ret_ref = tag_ptr(ret_copy, true);
8171         return ret_ref;
8172 }
8173
8174 static jclass LDKPaymentError_Invoice_class = NULL;
8175 static jmethodID LDKPaymentError_Invoice_meth = NULL;
8176 static jclass LDKPaymentError_Routing_class = NULL;
8177 static jmethodID LDKPaymentError_Routing_meth = NULL;
8178 static jclass LDKPaymentError_Sending_class = NULL;
8179 static jmethodID LDKPaymentError_Sending_meth = NULL;
8180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
8181         LDKPaymentError_Invoice_class =
8182                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
8183         CHECK(LDKPaymentError_Invoice_class != NULL);
8184         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
8185         CHECK(LDKPaymentError_Invoice_meth != NULL);
8186         LDKPaymentError_Routing_class =
8187                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
8188         CHECK(LDKPaymentError_Routing_class != NULL);
8189         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
8190         CHECK(LDKPaymentError_Routing_meth != NULL);
8191         LDKPaymentError_Sending_class =
8192                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
8193         CHECK(LDKPaymentError_Sending_class != NULL);
8194         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
8195         CHECK(LDKPaymentError_Sending_meth != NULL);
8196 }
8197 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8198         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
8199         switch(obj->tag) {
8200                 case LDKPaymentError_Invoice: {
8201                         LDKStr invoice_str = obj->invoice;
8202                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
8203                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
8204                 }
8205                 case LDKPaymentError_Routing: {
8206                         LDKLightningError routing_var = obj->routing;
8207                         int64_t routing_ref = 0;
8208                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
8209                         routing_ref = tag_ptr(routing_var.inner, false);
8210                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
8211                 }
8212                 case LDKPaymentError_Sending: {
8213                         int64_t sending_ref = tag_ptr(&obj->sending, false);
8214                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
8215                 }
8216                 default: abort();
8217         }
8218 }
8219 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8220 CHECK(owner->result_ok);
8221         return ThirtyTwoBytes_clone(&*owner->contents.result);
8222 }
8223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8224         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8225         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8226         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
8227         return ret_arr;
8228 }
8229
8230 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8231 CHECK(!owner->result_ok);
8232         return PaymentError_clone(&*owner->contents.err);
8233 }
8234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8235         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8236         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
8237         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
8238         int64_t ret_ref = tag_ptr(ret_copy, true);
8239         return ret_ref;
8240 }
8241
8242 static inline void CResult_NonePaymentErrorZ_get_ok(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
8243 CHECK(owner->result_ok);
8244         return *owner->contents.result;
8245 }
8246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8247         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
8248         CResult_NonePaymentErrorZ_get_ok(owner_conv);
8249 }
8250
8251 static inline struct LDKPaymentError CResult_NonePaymentErrorZ_get_err(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
8252 CHECK(!owner->result_ok);
8253         return PaymentError_clone(&*owner->contents.err);
8254 }
8255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8256         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
8257         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
8258         *ret_copy = CResult_NonePaymentErrorZ_get_err(owner_conv);
8259         int64_t ret_ref = tag_ptr(ret_copy, true);
8260         return ret_ref;
8261 }
8262
8263 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8264 CHECK(owner->result_ok);
8265         return *owner->contents.result;
8266 }
8267 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8268         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8269         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8270         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8271         return ret_conv;
8272 }
8273
8274 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8275 CHECK(!owner->result_ok);
8276         return *owner->contents.err;
8277 }
8278 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8279         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8280         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8281         return ret_conv;
8282 }
8283
8284 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
8285 CHECK(owner->result_ok);
8286         return *owner->contents.result;
8287 }
8288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8289         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
8290         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
8292         return ret_arr;
8293 }
8294
8295 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
8296 CHECK(!owner->result_ok);
8297         return *owner->contents.err;
8298 }
8299 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8300         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
8301         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
8302         return ret_conv;
8303 }
8304
8305 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8306         LDKChannelMonitorUpdate ret = *owner->contents.result;
8307         ret.is_owned = false;
8308         return ret;
8309 }
8310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8311         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8312         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8313         int64_t ret_ref = 0;
8314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8316         return ret_ref;
8317 }
8318
8319 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8320 CHECK(!owner->result_ok);
8321         return DecodeError_clone(&*owner->contents.err);
8322 }
8323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8324         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8325         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8326         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8327         int64_t ret_ref = tag_ptr(ret_copy, true);
8328         return ret_ref;
8329 }
8330
8331 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8332 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8333 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8334 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8336         LDKCOption_MonitorEventZ_Some_class =
8337                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8338         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8339         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8340         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8341         LDKCOption_MonitorEventZ_None_class =
8342                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8343         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8344         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8345         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8346 }
8347 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8348         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
8349         switch(obj->tag) {
8350                 case LDKCOption_MonitorEventZ_Some: {
8351                         int64_t some_ref = tag_ptr(&obj->some, false);
8352                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8353                 }
8354                 case LDKCOption_MonitorEventZ_None: {
8355                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8356                 }
8357                 default: abort();
8358         }
8359 }
8360 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8361 CHECK(owner->result_ok);
8362         return COption_MonitorEventZ_clone(&*owner->contents.result);
8363 }
8364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8365         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8366         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8367         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8368         int64_t ret_ref = tag_ptr(ret_copy, true);
8369         return ret_ref;
8370 }
8371
8372 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8373 CHECK(!owner->result_ok);
8374         return DecodeError_clone(&*owner->contents.err);
8375 }
8376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8377         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8378         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8379         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8380         int64_t ret_ref = tag_ptr(ret_copy, true);
8381         return ret_ref;
8382 }
8383
8384 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8385         LDKHTLCUpdate ret = *owner->contents.result;
8386         ret.is_owned = false;
8387         return ret;
8388 }
8389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8390         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8391         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8392         int64_t ret_ref = 0;
8393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8394         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8395         return ret_ref;
8396 }
8397
8398 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8399 CHECK(!owner->result_ok);
8400         return DecodeError_clone(&*owner->contents.err);
8401 }
8402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8403         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8404         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8405         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8406         int64_t ret_ref = tag_ptr(ret_copy, true);
8407         return ret_ref;
8408 }
8409
8410 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8411         LDKOutPoint ret = owner->a;
8412         ret.is_owned = false;
8413         return ret;
8414 }
8415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8416         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8417         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8418         int64_t ret_ref = 0;
8419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8420         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8421         return ret_ref;
8422 }
8423
8424 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8425         return CVec_u8Z_clone(&owner->b);
8426 }
8427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8428         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8429         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8430         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8431         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8432         CVec_u8Z_free(ret_var);
8433         return ret_arr;
8434 }
8435
8436 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8437         return owner->a;
8438 }
8439 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8440         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8441         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8442         return ret_conv;
8443 }
8444
8445 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8446         return CVec_u8Z_clone(&owner->b);
8447 }
8448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8449         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8450         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8451         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8452         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8453         CVec_u8Z_free(ret_var);
8454         return ret_arr;
8455 }
8456
8457 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8458         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8459         for (size_t i = 0; i < ret.datalen; i++) {
8460                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8461         }
8462         return ret;
8463 }
8464 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8465         return ThirtyTwoBytes_clone(&owner->a);
8466 }
8467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8468         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8469         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8471         return ret_arr;
8472 }
8473
8474 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8475         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8476 }
8477 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8478         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8479         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8480         int64_tArray ret_arr = NULL;
8481         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8482         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8483         for (size_t v = 0; v < ret_var.datalen; v++) {
8484                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8485                 *ret_conv_21_conv = ret_var.data[v];
8486                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
8487         }
8488         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8489         FREE(ret_var.data);
8490         return ret_arr;
8491 }
8492
8493 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8494         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 };
8495         for (size_t i = 0; i < ret.datalen; i++) {
8496                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8497         }
8498         return ret;
8499 }
8500 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8501         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8502         for (size_t i = 0; i < ret.datalen; i++) {
8503                 ret.data[i] = Event_clone(&orig->data[i]);
8504         }
8505         return ret;
8506 }
8507 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8508         return owner->a;
8509 }
8510 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8511         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8512         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8513         return ret_conv;
8514 }
8515
8516 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8517         return TxOut_clone(&owner->b);
8518 }
8519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8520         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8521         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8522         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8523         return tag_ptr(ret_ref, true);
8524 }
8525
8526 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8527         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8528         for (size_t i = 0; i < ret.datalen; i++) {
8529                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8530         }
8531         return ret;
8532 }
8533 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8534         return ThirtyTwoBytes_clone(&owner->a);
8535 }
8536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8537         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8538         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8540         return ret_arr;
8541 }
8542
8543 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8544         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8545 }
8546 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8547         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8548         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8549         int64_tArray ret_arr = NULL;
8550         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8551         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8552         for (size_t u = 0; u < ret_var.datalen; u++) {
8553                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8554                 *ret_conv_20_conv = ret_var.data[u];
8555                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
8556         }
8557         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8558         FREE(ret_var.data);
8559         return ret_arr;
8560 }
8561
8562 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8563         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 };
8564         for (size_t i = 0; i < ret.datalen; i++) {
8565                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8566         }
8567         return ret;
8568 }
8569 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8570 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8571 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8572 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8573 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8574 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8575 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
8576 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
8577 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
8578 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
8579 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
8580 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
8581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8582         LDKBalance_ClaimableOnChannelClose_class =
8583                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8584         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8585         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8586         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8587         LDKBalance_ClaimableAwaitingConfirmations_class =
8588                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8589         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8590         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8591         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8592         LDKBalance_ContentiousClaimable_class =
8593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8594         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8595         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8596         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8597         LDKBalance_MaybeTimeoutClaimableHTLC_class =
8598                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
8599         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
8600         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
8601         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
8602         LDKBalance_MaybePreimageClaimableHTLC_class =
8603                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
8604         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
8605         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
8606         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
8607         LDKBalance_CounterpartyRevokedOutputClaimable_class =
8608                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
8609         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
8610         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
8611         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
8612 }
8613 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8614         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
8615         switch(obj->tag) {
8616                 case LDKBalance_ClaimableOnChannelClose: {
8617                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8618                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8619                 }
8620                 case LDKBalance_ClaimableAwaitingConfirmations: {
8621                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8622                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8623                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8624                 }
8625                 case LDKBalance_ContentiousClaimable: {
8626                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8627                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8628                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8629                 }
8630                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
8631                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
8632                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
8633                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8634                 }
8635                 case LDKBalance_MaybePreimageClaimableHTLC: {
8636                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
8637                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
8638                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
8639                 }
8640                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
8641                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
8642                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
8643                 }
8644                 default: abort();
8645         }
8646 }
8647 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8648         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8649         for (size_t i = 0; i < ret.datalen; i++) {
8650                 ret.data[i] = Balance_clone(&orig->data[i]);
8651         }
8652         return ret;
8653 }
8654 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8655 CHECK(owner->result_ok);
8656         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8657 }
8658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8659         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8660         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8661         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8662         return tag_ptr(ret_conv, true);
8663 }
8664
8665 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8666 CHECK(!owner->result_ok);
8667         return DecodeError_clone(&*owner->contents.err);
8668 }
8669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8670         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8671         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8672         *ret_copy = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8673         int64_t ret_ref = tag_ptr(ret_copy, true);
8674         return ret_ref;
8675 }
8676
8677 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8678         return owner->a;
8679 }
8680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8681         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8682         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8683         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8684         return ret_arr;
8685 }
8686
8687 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8688         return Type_clone(&owner->b);
8689 }
8690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8691         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8692         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8693         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8694         return tag_ptr(ret_ret, true);
8695 }
8696
8697 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8698         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8699         for (size_t i = 0; i < ret.datalen; i++) {
8700                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8701         }
8702         return ret;
8703 }
8704 typedef struct LDKCustomOnionMessageContents_JCalls {
8705         atomic_size_t refcnt;
8706         JavaVM *vm;
8707         jweak o;
8708         jmethodID tlv_type_meth;
8709         jmethodID write_meth;
8710 } LDKCustomOnionMessageContents_JCalls;
8711 static void LDKCustomOnionMessageContents_JCalls_free(void* this_arg) {
8712         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8713         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8714                 JNIEnv *env;
8715                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8716                 if (get_jenv_res == JNI_EDETACHED) {
8717                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8718                 } else {
8719                         DO_ASSERT(get_jenv_res == JNI_OK);
8720                 }
8721                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8722                 if (get_jenv_res == JNI_EDETACHED) {
8723                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8724                 }
8725                 FREE(j_calls);
8726         }
8727 }
8728 uint64_t tlv_type_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
8729         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8730         JNIEnv *env;
8731         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8732         if (get_jenv_res == JNI_EDETACHED) {
8733                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8734         } else {
8735                 DO_ASSERT(get_jenv_res == JNI_OK);
8736         }
8737         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8738         CHECK(obj != NULL);
8739         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->tlv_type_meth);
8740         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8741                 (*env)->ExceptionDescribe(env);
8742                 (*env)->FatalError(env, "A call to tlv_type in LDKCustomOnionMessageContents from rust threw an exception.");
8743         }
8744         if (get_jenv_res == JNI_EDETACHED) {
8745                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8746         }
8747         return ret;
8748 }
8749 LDKCVec_u8Z write_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
8750         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8751         JNIEnv *env;
8752         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8753         if (get_jenv_res == JNI_EDETACHED) {
8754                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8755         } else {
8756                 DO_ASSERT(get_jenv_res == JNI_OK);
8757         }
8758         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8759         CHECK(obj != NULL);
8760         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
8761         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8762                 (*env)->ExceptionDescribe(env);
8763                 (*env)->FatalError(env, "A call to write in LDKCustomOnionMessageContents from rust threw an exception.");
8764         }
8765         LDKCVec_u8Z ret_ref;
8766         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8767         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8768         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8769         if (get_jenv_res == JNI_EDETACHED) {
8770                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8771         }
8772         return ret_ref;
8773 }
8774 static void LDKCustomOnionMessageContents_JCalls_cloned(LDKCustomOnionMessageContents* new_obj) {
8775         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) new_obj->this_arg;
8776         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8777 }
8778 static inline LDKCustomOnionMessageContents LDKCustomOnionMessageContents_init (JNIEnv *env, jclass clz, jobject o) {
8779         jclass c = (*env)->GetObjectClass(env, o);
8780         CHECK(c != NULL);
8781         LDKCustomOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageContents_JCalls), "LDKCustomOnionMessageContents_JCalls");
8782         atomic_init(&calls->refcnt, 1);
8783         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8784         calls->o = (*env)->NewWeakGlobalRef(env, o);
8785         calls->tlv_type_meth = (*env)->GetMethodID(env, c, "tlv_type", "()J");
8786         CHECK(calls->tlv_type_meth != NULL);
8787         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
8788         CHECK(calls->write_meth != NULL);
8789
8790         LDKCustomOnionMessageContents ret = {
8791                 .this_arg = (void*) calls,
8792                 .tlv_type = tlv_type_LDKCustomOnionMessageContents_jcall,
8793                 .write = write_LDKCustomOnionMessageContents_jcall,
8794                 .cloned = LDKCustomOnionMessageContents_JCalls_cloned,
8795                 .free = LDKCustomOnionMessageContents_JCalls_free,
8796         };
8797         return ret;
8798 }
8799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageContents_1new(JNIEnv *env, jclass clz, jobject o) {
8800         LDKCustomOnionMessageContents *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
8801         *res_ptr = LDKCustomOnionMessageContents_init(env, clz, o);
8802         return tag_ptr(res_ptr, true);
8803 }
8804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1tlv_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
8805         void* this_arg_ptr = untag_ptr(this_arg);
8806         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8807         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
8808         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
8809         return ret_conv;
8810 }
8811
8812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
8813         void* this_arg_ptr = untag_ptr(this_arg);
8814         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8815         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
8816         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8817         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8818         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8819         CVec_u8Z_free(ret_var);
8820         return ret_arr;
8821 }
8822
8823 static jclass LDKCOption_CustomOnionMessageContentsZ_Some_class = NULL;
8824 static jmethodID LDKCOption_CustomOnionMessageContentsZ_Some_meth = NULL;
8825 static jclass LDKCOption_CustomOnionMessageContentsZ_None_class = NULL;
8826 static jmethodID LDKCOption_CustomOnionMessageContentsZ_None_meth = NULL;
8827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CustomOnionMessageContentsZ_init (JNIEnv *env, jclass clz) {
8828         LDKCOption_CustomOnionMessageContentsZ_Some_class =
8829                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$Some"));
8830         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_class != NULL);
8831         LDKCOption_CustomOnionMessageContentsZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, "<init>", "(J)V");
8832         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_meth != NULL);
8833         LDKCOption_CustomOnionMessageContentsZ_None_class =
8834                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$None"));
8835         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_class != NULL);
8836         LDKCOption_CustomOnionMessageContentsZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_None_class, "<init>", "()V");
8837         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_meth != NULL);
8838 }
8839 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CustomOnionMessageContentsZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8840         LDKCOption_CustomOnionMessageContentsZ *obj = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(ptr);
8841         switch(obj->tag) {
8842                 case LDKCOption_CustomOnionMessageContentsZ_Some: {
8843                         LDKCustomOnionMessageContents* some_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
8844                         *some_ret = CustomOnionMessageContents_clone(&obj->some);
8845                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, LDKCOption_CustomOnionMessageContentsZ_Some_meth, tag_ptr(some_ret, true));
8846                 }
8847                 case LDKCOption_CustomOnionMessageContentsZ_None: {
8848                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_None_class, LDKCOption_CustomOnionMessageContentsZ_None_meth);
8849                 }
8850                 default: abort();
8851         }
8852 }
8853 static inline struct LDKCOption_CustomOnionMessageContentsZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
8854 CHECK(owner->result_ok);
8855         return COption_CustomOnionMessageContentsZ_clone(&*owner->contents.result);
8856 }
8857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8858         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
8859         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
8860         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
8861         int64_t ret_ref = tag_ptr(ret_copy, true);
8862         return ret_ref;
8863 }
8864
8865 static inline struct LDKDecodeError CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
8866 CHECK(!owner->result_ok);
8867         return DecodeError_clone(&*owner->contents.err);
8868 }
8869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8870         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
8871         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8872         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
8873         int64_t ret_ref = tag_ptr(ret_copy, true);
8874         return ret_ref;
8875 }
8876
8877 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8878 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8879 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8880 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8882         LDKCOption_NetAddressZ_Some_class =
8883                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8884         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8885         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8886         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8887         LDKCOption_NetAddressZ_None_class =
8888                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8889         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8890         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8891         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8892 }
8893 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8894         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
8895         switch(obj->tag) {
8896                 case LDKCOption_NetAddressZ_Some: {
8897                         int64_t some_ref = tag_ptr(&obj->some, false);
8898                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8899                 }
8900                 case LDKCOption_NetAddressZ_None: {
8901                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8902                 }
8903                 default: abort();
8904         }
8905 }
8906 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8907 CHECK(owner->result_ok);
8908         return CVec_u8Z_clone(&*owner->contents.result);
8909 }
8910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8911         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
8912         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8913         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8914         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8915         CVec_u8Z_free(ret_var);
8916         return ret_arr;
8917 }
8918
8919 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8920         LDKPeerHandleError ret = *owner->contents.err;
8921         ret.is_owned = false;
8922         return ret;
8923 }
8924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8925         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
8926         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8927         int64_t ret_ref = 0;
8928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8930         return ret_ref;
8931 }
8932
8933 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8934 CHECK(owner->result_ok);
8935         return *owner->contents.result;
8936 }
8937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8938         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
8939         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8940 }
8941
8942 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8943         LDKPeerHandleError ret = *owner->contents.err;
8944         ret.is_owned = false;
8945         return ret;
8946 }
8947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8948         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
8949         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8950         int64_t ret_ref = 0;
8951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8953         return ret_ref;
8954 }
8955
8956 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8957 CHECK(owner->result_ok);
8958         return *owner->contents.result;
8959 }
8960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8961         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
8962         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8963         return ret_conv;
8964 }
8965
8966 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8967         LDKPeerHandleError ret = *owner->contents.err;
8968         ret.is_owned = false;
8969         return ret;
8970 }
8971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8972         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
8973         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8974         int64_t ret_ref = 0;
8975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8977         return ret_ref;
8978 }
8979
8980 static jclass LDKSendError_Secp256k1_class = NULL;
8981 static jmethodID LDKSendError_Secp256k1_meth = NULL;
8982 static jclass LDKSendError_TooBigPacket_class = NULL;
8983 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
8984 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
8985 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
8986 static jclass LDKSendError_InvalidFirstHop_class = NULL;
8987 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
8988 static jclass LDKSendError_InvalidMessage_class = NULL;
8989 static jmethodID LDKSendError_InvalidMessage_meth = NULL;
8990 static jclass LDKSendError_BufferFull_class = NULL;
8991 static jmethodID LDKSendError_BufferFull_meth = NULL;
8992 static jclass LDKSendError_GetNodeIdFailed_class = NULL;
8993 static jmethodID LDKSendError_GetNodeIdFailed_meth = NULL;
8994 static jclass LDKSendError_BlindedPathAdvanceFailed_class = NULL;
8995 static jmethodID LDKSendError_BlindedPathAdvanceFailed_meth = NULL;
8996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
8997         LDKSendError_Secp256k1_class =
8998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
8999         CHECK(LDKSendError_Secp256k1_class != NULL);
9000         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9001         CHECK(LDKSendError_Secp256k1_meth != NULL);
9002         LDKSendError_TooBigPacket_class =
9003                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
9004         CHECK(LDKSendError_TooBigPacket_class != NULL);
9005         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
9006         CHECK(LDKSendError_TooBigPacket_meth != NULL);
9007         LDKSendError_TooFewBlindedHops_class =
9008                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
9009         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
9010         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
9011         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
9012         LDKSendError_InvalidFirstHop_class =
9013                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
9014         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
9015         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
9016         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
9017         LDKSendError_InvalidMessage_class =
9018                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidMessage"));
9019         CHECK(LDKSendError_InvalidMessage_class != NULL);
9020         LDKSendError_InvalidMessage_meth = (*env)->GetMethodID(env, LDKSendError_InvalidMessage_class, "<init>", "()V");
9021         CHECK(LDKSendError_InvalidMessage_meth != NULL);
9022         LDKSendError_BufferFull_class =
9023                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
9024         CHECK(LDKSendError_BufferFull_class != NULL);
9025         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
9026         CHECK(LDKSendError_BufferFull_meth != NULL);
9027         LDKSendError_GetNodeIdFailed_class =
9028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$GetNodeIdFailed"));
9029         CHECK(LDKSendError_GetNodeIdFailed_class != NULL);
9030         LDKSendError_GetNodeIdFailed_meth = (*env)->GetMethodID(env, LDKSendError_GetNodeIdFailed_class, "<init>", "()V");
9031         CHECK(LDKSendError_GetNodeIdFailed_meth != NULL);
9032         LDKSendError_BlindedPathAdvanceFailed_class =
9033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BlindedPathAdvanceFailed"));
9034         CHECK(LDKSendError_BlindedPathAdvanceFailed_class != NULL);
9035         LDKSendError_BlindedPathAdvanceFailed_meth = (*env)->GetMethodID(env, LDKSendError_BlindedPathAdvanceFailed_class, "<init>", "()V");
9036         CHECK(LDKSendError_BlindedPathAdvanceFailed_meth != NULL);
9037 }
9038 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9039         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
9040         switch(obj->tag) {
9041                 case LDKSendError_Secp256k1: {
9042                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
9043                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
9044                 }
9045                 case LDKSendError_TooBigPacket: {
9046                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
9047                 }
9048                 case LDKSendError_TooFewBlindedHops: {
9049                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
9050                 }
9051                 case LDKSendError_InvalidFirstHop: {
9052                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
9053                 }
9054                 case LDKSendError_InvalidMessage: {
9055                         return (*env)->NewObject(env, LDKSendError_InvalidMessage_class, LDKSendError_InvalidMessage_meth);
9056                 }
9057                 case LDKSendError_BufferFull: {
9058                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
9059                 }
9060                 case LDKSendError_GetNodeIdFailed: {
9061                         return (*env)->NewObject(env, LDKSendError_GetNodeIdFailed_class, LDKSendError_GetNodeIdFailed_meth);
9062                 }
9063                 case LDKSendError_BlindedPathAdvanceFailed: {
9064                         return (*env)->NewObject(env, LDKSendError_BlindedPathAdvanceFailed_class, LDKSendError_BlindedPathAdvanceFailed_meth);
9065                 }
9066                 default: abort();
9067         }
9068 }
9069 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9070 CHECK(owner->result_ok);
9071         return *owner->contents.result;
9072 }
9073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9074         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9075         CResult_NoneSendErrorZ_get_ok(owner_conv);
9076 }
9077
9078 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9079 CHECK(!owner->result_ok);
9080         return SendError_clone(&*owner->contents.err);
9081 }
9082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9083         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9084         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
9085         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
9086         int64_t ret_ref = tag_ptr(ret_copy, true);
9087         return ret_ref;
9088 }
9089
9090 static jclass LDKParseError_Bech32Error_class = NULL;
9091 static jmethodID LDKParseError_Bech32Error_meth = NULL;
9092 static jclass LDKParseError_ParseAmountError_class = NULL;
9093 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
9094 static jclass LDKParseError_MalformedSignature_class = NULL;
9095 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
9096 static jclass LDKParseError_BadPrefix_class = NULL;
9097 static jmethodID LDKParseError_BadPrefix_meth = NULL;
9098 static jclass LDKParseError_UnknownCurrency_class = NULL;
9099 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
9100 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
9101 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
9102 static jclass LDKParseError_MalformedHRP_class = NULL;
9103 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
9104 static jclass LDKParseError_TooShortDataPart_class = NULL;
9105 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
9106 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
9107 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
9108 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
9109 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
9110 static jclass LDKParseError_PaddingError_class = NULL;
9111 static jmethodID LDKParseError_PaddingError_meth = NULL;
9112 static jclass LDKParseError_IntegerOverflowError_class = NULL;
9113 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
9114 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
9115 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
9116 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
9117 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
9118 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
9119 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
9120 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
9121 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
9122 static jclass LDKParseError_InvalidSliceLength_class = NULL;
9123 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
9124 static jclass LDKParseError_Skip_class = NULL;
9125 static jmethodID LDKParseError_Skip_meth = NULL;
9126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
9127         LDKParseError_Bech32Error_class =
9128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
9129         CHECK(LDKParseError_Bech32Error_class != NULL);
9130         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
9131         CHECK(LDKParseError_Bech32Error_meth != NULL);
9132         LDKParseError_ParseAmountError_class =
9133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
9134         CHECK(LDKParseError_ParseAmountError_class != NULL);
9135         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
9136         CHECK(LDKParseError_ParseAmountError_meth != NULL);
9137         LDKParseError_MalformedSignature_class =
9138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
9139         CHECK(LDKParseError_MalformedSignature_class != NULL);
9140         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9141         CHECK(LDKParseError_MalformedSignature_meth != NULL);
9142         LDKParseError_BadPrefix_class =
9143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
9144         CHECK(LDKParseError_BadPrefix_class != NULL);
9145         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
9146         CHECK(LDKParseError_BadPrefix_meth != NULL);
9147         LDKParseError_UnknownCurrency_class =
9148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
9149         CHECK(LDKParseError_UnknownCurrency_class != NULL);
9150         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
9151         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
9152         LDKParseError_UnknownSiPrefix_class =
9153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
9154         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
9155         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
9156         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
9157         LDKParseError_MalformedHRP_class =
9158                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
9159         CHECK(LDKParseError_MalformedHRP_class != NULL);
9160         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
9161         CHECK(LDKParseError_MalformedHRP_meth != NULL);
9162         LDKParseError_TooShortDataPart_class =
9163                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
9164         CHECK(LDKParseError_TooShortDataPart_class != NULL);
9165         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
9166         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
9167         LDKParseError_UnexpectedEndOfTaggedFields_class =
9168                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
9169         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
9170         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
9171         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
9172         LDKParseError_DescriptionDecodeError_class =
9173                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
9174         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
9175         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
9176         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
9177         LDKParseError_PaddingError_class =
9178                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
9179         CHECK(LDKParseError_PaddingError_class != NULL);
9180         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
9181         CHECK(LDKParseError_PaddingError_meth != NULL);
9182         LDKParseError_IntegerOverflowError_class =
9183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
9184         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
9185         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
9186         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
9187         LDKParseError_InvalidSegWitProgramLength_class =
9188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
9189         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
9190         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
9191         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
9192         LDKParseError_InvalidPubKeyHashLength_class =
9193                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
9194         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
9195         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
9196         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
9197         LDKParseError_InvalidScriptHashLength_class =
9198                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
9199         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
9200         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
9201         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
9202         LDKParseError_InvalidRecoveryId_class =
9203                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
9204         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
9205         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
9206         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
9207         LDKParseError_InvalidSliceLength_class =
9208                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
9209         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
9210         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
9211         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
9212         LDKParseError_Skip_class =
9213                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
9214         CHECK(LDKParseError_Skip_class != NULL);
9215         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
9216         CHECK(LDKParseError_Skip_meth != NULL);
9217 }
9218 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9219         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
9220         switch(obj->tag) {
9221                 case LDKParseError_Bech32Error: {
9222                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
9223                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
9224                 }
9225                 case LDKParseError_ParseAmountError: {
9226                         /*obj->parse_amount_error*/
9227                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
9228                 }
9229                 case LDKParseError_MalformedSignature: {
9230                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
9231                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
9232                 }
9233                 case LDKParseError_BadPrefix: {
9234                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
9235                 }
9236                 case LDKParseError_UnknownCurrency: {
9237                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
9238                 }
9239                 case LDKParseError_UnknownSiPrefix: {
9240                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
9241                 }
9242                 case LDKParseError_MalformedHRP: {
9243                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
9244                 }
9245                 case LDKParseError_TooShortDataPart: {
9246                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
9247                 }
9248                 case LDKParseError_UnexpectedEndOfTaggedFields: {
9249                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
9250                 }
9251                 case LDKParseError_DescriptionDecodeError: {
9252                         /*obj->description_decode_error*/
9253                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
9254                 }
9255                 case LDKParseError_PaddingError: {
9256                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
9257                 }
9258                 case LDKParseError_IntegerOverflowError: {
9259                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
9260                 }
9261                 case LDKParseError_InvalidSegWitProgramLength: {
9262                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
9263                 }
9264                 case LDKParseError_InvalidPubKeyHashLength: {
9265                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
9266                 }
9267                 case LDKParseError_InvalidScriptHashLength: {
9268                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
9269                 }
9270                 case LDKParseError_InvalidRecoveryId: {
9271                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
9272                 }
9273                 case LDKParseError_InvalidSliceLength: {
9274                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
9275                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
9276                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
9277                 }
9278                 case LDKParseError_Skip: {
9279                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
9280                 }
9281                 default: abort();
9282         }
9283 }
9284 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
9285 CHECK(owner->result_ok);
9286         return SiPrefix_clone(&*owner->contents.result);
9287 }
9288 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9289         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
9290         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
9291         return ret_conv;
9292 }
9293
9294 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
9295 CHECK(!owner->result_ok);
9296         return ParseError_clone(&*owner->contents.err);
9297 }
9298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9299         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
9300         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
9301         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
9302         int64_t ret_ref = tag_ptr(ret_copy, true);
9303         return ret_ref;
9304 }
9305
9306 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
9307 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
9308 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
9309 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
9310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
9311         LDKParseOrSemanticError_ParseError_class =
9312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
9313         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
9314         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
9315         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
9316         LDKParseOrSemanticError_SemanticError_class =
9317                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
9318         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
9319         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
9320         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
9321 }
9322 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9323         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
9324         switch(obj->tag) {
9325                 case LDKParseOrSemanticError_ParseError: {
9326                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
9327                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
9328                 }
9329                 case LDKParseOrSemanticError_SemanticError: {
9330                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
9331                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
9332                 }
9333                 default: abort();
9334         }
9335 }
9336 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
9337         LDKInvoice ret = *owner->contents.result;
9338         ret.is_owned = false;
9339         return ret;
9340 }
9341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9342         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
9343         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
9344         int64_t ret_ref = 0;
9345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9347         return ret_ref;
9348 }
9349
9350 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
9351 CHECK(!owner->result_ok);
9352         return ParseOrSemanticError_clone(&*owner->contents.err);
9353 }
9354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9355         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
9356         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
9357         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
9358         int64_t ret_ref = tag_ptr(ret_copy, true);
9359         return ret_ref;
9360 }
9361
9362 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
9363         LDKSignedRawInvoice ret = *owner->contents.result;
9364         ret.is_owned = false;
9365         return ret;
9366 }
9367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9368         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
9369         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
9370         int64_t ret_ref = 0;
9371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9372         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9373         return ret_ref;
9374 }
9375
9376 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
9377 CHECK(!owner->result_ok);
9378         return ParseError_clone(&*owner->contents.err);
9379 }
9380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9381         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
9382         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
9383         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
9384         int64_t ret_ref = tag_ptr(ret_copy, true);
9385         return ret_ref;
9386 }
9387
9388 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
9389         LDKRawInvoice ret = owner->a;
9390         ret.is_owned = false;
9391         return ret;
9392 }
9393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9394         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
9395         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
9396         int64_t ret_ref = 0;
9397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9398         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9399         return ret_ref;
9400 }
9401
9402 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
9403         return ThirtyTwoBytes_clone(&owner->b);
9404 }
9405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9406         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
9407         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9408         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
9409         return ret_arr;
9410 }
9411
9412 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
9413         LDKInvoiceSignature ret = owner->c;
9414         ret.is_owned = false;
9415         return ret;
9416 }
9417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
9418         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
9419         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
9420         int64_t ret_ref = 0;
9421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9423         return ret_ref;
9424 }
9425
9426 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
9427         LDKPayeePubKey ret = *owner->contents.result;
9428         ret.is_owned = false;
9429         return ret;
9430 }
9431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9432         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
9433         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
9434         int64_t ret_ref = 0;
9435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9436         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9437         return ret_ref;
9438 }
9439
9440 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
9441 CHECK(!owner->result_ok);
9442         return *owner->contents.err;
9443 }
9444 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9445         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
9446         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
9447         return ret_conv;
9448 }
9449
9450 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
9451         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
9452         for (size_t i = 0; i < ret.datalen; i++) {
9453                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
9454         }
9455         return ret;
9456 }
9457 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
9458         LDKPositiveTimestamp ret = *owner->contents.result;
9459         ret.is_owned = false;
9460         return ret;
9461 }
9462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9463         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
9464         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
9465         int64_t ret_ref = 0;
9466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9467         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9468         return ret_ref;
9469 }
9470
9471 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
9472 CHECK(!owner->result_ok);
9473         return CreationError_clone(&*owner->contents.err);
9474 }
9475 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9476         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
9477         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
9478         return ret_conv;
9479 }
9480
9481 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
9482 CHECK(owner->result_ok);
9483         return *owner->contents.result;
9484 }
9485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9486         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
9487         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
9488 }
9489
9490 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
9491 CHECK(!owner->result_ok);
9492         return SemanticError_clone(&*owner->contents.err);
9493 }
9494 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9495         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
9496         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
9497         return ret_conv;
9498 }
9499
9500 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
9501         LDKInvoice ret = *owner->contents.result;
9502         ret.is_owned = false;
9503         return ret;
9504 }
9505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9506         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
9507         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
9508         int64_t ret_ref = 0;
9509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9511         return ret_ref;
9512 }
9513
9514 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
9515 CHECK(!owner->result_ok);
9516         return SemanticError_clone(&*owner->contents.err);
9517 }
9518 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9519         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
9520         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
9521         return ret_conv;
9522 }
9523
9524 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
9525         LDKDescription ret = *owner->contents.result;
9526         ret.is_owned = false;
9527         return ret;
9528 }
9529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9530         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
9531         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
9532         int64_t ret_ref = 0;
9533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9535         return ret_ref;
9536 }
9537
9538 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
9539 CHECK(!owner->result_ok);
9540         return CreationError_clone(&*owner->contents.err);
9541 }
9542 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9543         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
9544         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
9545         return ret_conv;
9546 }
9547
9548 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
9549         LDKPrivateRoute ret = *owner->contents.result;
9550         ret.is_owned = false;
9551         return ret;
9552 }
9553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9554         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
9555         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
9556         int64_t ret_ref = 0;
9557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9558         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9559         return ret_ref;
9560 }
9561
9562 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
9563 CHECK(!owner->result_ok);
9564         return CreationError_clone(&*owner->contents.err);
9565 }
9566 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9567         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
9568         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
9569         return ret_conv;
9570 }
9571
9572 static jclass LDKGraphSyncError_DecodeError_class = NULL;
9573 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
9574 static jclass LDKGraphSyncError_LightningError_class = NULL;
9575 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
9576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
9577         LDKGraphSyncError_DecodeError_class =
9578                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
9579         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
9580         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
9581         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
9582         LDKGraphSyncError_LightningError_class =
9583                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
9584         CHECK(LDKGraphSyncError_LightningError_class != NULL);
9585         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
9586         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
9587 }
9588 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9589         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
9590         switch(obj->tag) {
9591                 case LDKGraphSyncError_DecodeError: {
9592                         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
9593                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
9594                 }
9595                 case LDKGraphSyncError_LightningError: {
9596                         LDKLightningError lightning_error_var = obj->lightning_error;
9597                         int64_t lightning_error_ref = 0;
9598                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
9599                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
9600                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
9601                 }
9602                 default: abort();
9603         }
9604 }
9605 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9606 CHECK(owner->result_ok);
9607         return *owner->contents.result;
9608 }
9609 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9610         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9611         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
9612         return ret_conv;
9613 }
9614
9615 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9616 CHECK(!owner->result_ok);
9617         return GraphSyncError_clone(&*owner->contents.err);
9618 }
9619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9620         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9621         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
9622         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
9623         int64_t ret_ref = tag_ptr(ret_copy, true);
9624         return ret_ref;
9625 }
9626
9627 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9628 CHECK(owner->result_ok);
9629         return NetAddress_clone(&*owner->contents.result);
9630 }
9631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9632         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9633         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9634         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
9635         int64_t ret_ref = tag_ptr(ret_copy, true);
9636         return ret_ref;
9637 }
9638
9639 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9640 CHECK(!owner->result_ok);
9641         return DecodeError_clone(&*owner->contents.err);
9642 }
9643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9644         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9645         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9646         *ret_copy = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
9647         int64_t ret_ref = tag_ptr(ret_copy, true);
9648         return ret_ref;
9649 }
9650
9651 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
9652         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
9653         for (size_t i = 0; i < ret.datalen; i++) {
9654                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
9655         }
9656         return ret;
9657 }
9658 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
9659         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
9660         for (size_t i = 0; i < ret.datalen; i++) {
9661                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
9662         }
9663         return ret;
9664 }
9665 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
9666         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
9667         for (size_t i = 0; i < ret.datalen; i++) {
9668                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
9669         }
9670         return ret;
9671 }
9672 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
9673         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
9674         for (size_t i = 0; i < ret.datalen; i++) {
9675                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
9676         }
9677         return ret;
9678 }
9679 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9680         LDKAcceptChannel ret = *owner->contents.result;
9681         ret.is_owned = false;
9682         return ret;
9683 }
9684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9685         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9686         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
9687         int64_t ret_ref = 0;
9688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9690         return ret_ref;
9691 }
9692
9693 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9694 CHECK(!owner->result_ok);
9695         return DecodeError_clone(&*owner->contents.err);
9696 }
9697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9698         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9699         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9700         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
9701         int64_t ret_ref = tag_ptr(ret_copy, true);
9702         return ret_ref;
9703 }
9704
9705 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9706         LDKAnnouncementSignatures ret = *owner->contents.result;
9707         ret.is_owned = false;
9708         return ret;
9709 }
9710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9711         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9712         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
9713         int64_t ret_ref = 0;
9714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9716         return ret_ref;
9717 }
9718
9719 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9720 CHECK(!owner->result_ok);
9721         return DecodeError_clone(&*owner->contents.err);
9722 }
9723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9724         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9725         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9726         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
9727         int64_t ret_ref = tag_ptr(ret_copy, true);
9728         return ret_ref;
9729 }
9730
9731 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9732         LDKChannelReestablish ret = *owner->contents.result;
9733         ret.is_owned = false;
9734         return ret;
9735 }
9736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9737         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9738         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
9739         int64_t ret_ref = 0;
9740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9742         return ret_ref;
9743 }
9744
9745 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9746 CHECK(!owner->result_ok);
9747         return DecodeError_clone(&*owner->contents.err);
9748 }
9749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9750         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9751         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9752         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
9753         int64_t ret_ref = tag_ptr(ret_copy, true);
9754         return ret_ref;
9755 }
9756
9757 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9758         LDKClosingSigned ret = *owner->contents.result;
9759         ret.is_owned = false;
9760         return ret;
9761 }
9762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9763         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9764         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
9765         int64_t ret_ref = 0;
9766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9768         return ret_ref;
9769 }
9770
9771 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9772 CHECK(!owner->result_ok);
9773         return DecodeError_clone(&*owner->contents.err);
9774 }
9775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9776         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9777         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9778         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9779         int64_t ret_ref = tag_ptr(ret_copy, true);
9780         return ret_ref;
9781 }
9782
9783 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9784         LDKClosingSignedFeeRange ret = *owner->contents.result;
9785         ret.is_owned = false;
9786         return ret;
9787 }
9788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9789         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9790         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9791         int64_t ret_ref = 0;
9792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9794         return ret_ref;
9795 }
9796
9797 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9798 CHECK(!owner->result_ok);
9799         return DecodeError_clone(&*owner->contents.err);
9800 }
9801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9802         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9803         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9804         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9805         int64_t ret_ref = tag_ptr(ret_copy, true);
9806         return ret_ref;
9807 }
9808
9809 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9810         LDKCommitmentSigned ret = *owner->contents.result;
9811         ret.is_owned = false;
9812         return ret;
9813 }
9814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9815         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9816         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9817         int64_t ret_ref = 0;
9818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9820         return ret_ref;
9821 }
9822
9823 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9824 CHECK(!owner->result_ok);
9825         return DecodeError_clone(&*owner->contents.err);
9826 }
9827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9828         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9829         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9830         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9831         int64_t ret_ref = tag_ptr(ret_copy, true);
9832         return ret_ref;
9833 }
9834
9835 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9836         LDKFundingCreated ret = *owner->contents.result;
9837         ret.is_owned = false;
9838         return ret;
9839 }
9840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9841         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9842         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9843         int64_t ret_ref = 0;
9844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9845         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9846         return ret_ref;
9847 }
9848
9849 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9850 CHECK(!owner->result_ok);
9851         return DecodeError_clone(&*owner->contents.err);
9852 }
9853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9854         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9855         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9856         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9857         int64_t ret_ref = tag_ptr(ret_copy, true);
9858         return ret_ref;
9859 }
9860
9861 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9862         LDKFundingSigned ret = *owner->contents.result;
9863         ret.is_owned = false;
9864         return ret;
9865 }
9866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9867         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9868         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9869         int64_t ret_ref = 0;
9870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9872         return ret_ref;
9873 }
9874
9875 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9876 CHECK(!owner->result_ok);
9877         return DecodeError_clone(&*owner->contents.err);
9878 }
9879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9880         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9881         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9882         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9883         int64_t ret_ref = tag_ptr(ret_copy, true);
9884         return ret_ref;
9885 }
9886
9887 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9888         LDKChannelReady ret = *owner->contents.result;
9889         ret.is_owned = false;
9890         return ret;
9891 }
9892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9893         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9894         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9895         int64_t ret_ref = 0;
9896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9897         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9898         return ret_ref;
9899 }
9900
9901 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9902 CHECK(!owner->result_ok);
9903         return DecodeError_clone(&*owner->contents.err);
9904 }
9905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9906         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9907         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9908         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9909         int64_t ret_ref = tag_ptr(ret_copy, true);
9910         return ret_ref;
9911 }
9912
9913 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9914         LDKInit ret = *owner->contents.result;
9915         ret.is_owned = false;
9916         return ret;
9917 }
9918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9919         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9920         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9921         int64_t ret_ref = 0;
9922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9924         return ret_ref;
9925 }
9926
9927 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9928 CHECK(!owner->result_ok);
9929         return DecodeError_clone(&*owner->contents.err);
9930 }
9931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9932         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9933         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9934         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
9935         int64_t ret_ref = tag_ptr(ret_copy, true);
9936         return ret_ref;
9937 }
9938
9939 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9940         LDKOpenChannel ret = *owner->contents.result;
9941         ret.is_owned = false;
9942         return ret;
9943 }
9944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9945         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9946         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9947         int64_t ret_ref = 0;
9948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9949         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9950         return ret_ref;
9951 }
9952
9953 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9954 CHECK(!owner->result_ok);
9955         return DecodeError_clone(&*owner->contents.err);
9956 }
9957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9958         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9959         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9960         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9961         int64_t ret_ref = tag_ptr(ret_copy, true);
9962         return ret_ref;
9963 }
9964
9965 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9966         LDKRevokeAndACK ret = *owner->contents.result;
9967         ret.is_owned = false;
9968         return ret;
9969 }
9970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9971         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9972         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9973         int64_t ret_ref = 0;
9974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9975         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9976         return ret_ref;
9977 }
9978
9979 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9980 CHECK(!owner->result_ok);
9981         return DecodeError_clone(&*owner->contents.err);
9982 }
9983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9984         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9985         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9986         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9987         int64_t ret_ref = tag_ptr(ret_copy, true);
9988         return ret_ref;
9989 }
9990
9991 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9992         LDKShutdown ret = *owner->contents.result;
9993         ret.is_owned = false;
9994         return ret;
9995 }
9996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9997         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
9998         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9999         int64_t ret_ref = 0;
10000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10002         return ret_ref;
10003 }
10004
10005 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
10006 CHECK(!owner->result_ok);
10007         return DecodeError_clone(&*owner->contents.err);
10008 }
10009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10010         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
10011         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10012         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
10013         int64_t ret_ref = tag_ptr(ret_copy, true);
10014         return ret_ref;
10015 }
10016
10017 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
10018         LDKUpdateFailHTLC ret = *owner->contents.result;
10019         ret.is_owned = false;
10020         return ret;
10021 }
10022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10023         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
10024         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
10025         int64_t ret_ref = 0;
10026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10028         return ret_ref;
10029 }
10030
10031 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
10032 CHECK(!owner->result_ok);
10033         return DecodeError_clone(&*owner->contents.err);
10034 }
10035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10036         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
10037         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10038         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
10039         int64_t ret_ref = tag_ptr(ret_copy, true);
10040         return ret_ref;
10041 }
10042
10043 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
10044         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
10045         ret.is_owned = false;
10046         return ret;
10047 }
10048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10049         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
10050         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
10051         int64_t ret_ref = 0;
10052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10054         return ret_ref;
10055 }
10056
10057 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
10058 CHECK(!owner->result_ok);
10059         return DecodeError_clone(&*owner->contents.err);
10060 }
10061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10062         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
10063         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10064         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
10065         int64_t ret_ref = tag_ptr(ret_copy, true);
10066         return ret_ref;
10067 }
10068
10069 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
10070         LDKUpdateFee ret = *owner->contents.result;
10071         ret.is_owned = false;
10072         return ret;
10073 }
10074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10075         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
10076         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
10077         int64_t ret_ref = 0;
10078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10080         return ret_ref;
10081 }
10082
10083 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
10084 CHECK(!owner->result_ok);
10085         return DecodeError_clone(&*owner->contents.err);
10086 }
10087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10088         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
10089         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10090         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
10091         int64_t ret_ref = tag_ptr(ret_copy, true);
10092         return ret_ref;
10093 }
10094
10095 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
10096         LDKUpdateFulfillHTLC ret = *owner->contents.result;
10097         ret.is_owned = false;
10098         return ret;
10099 }
10100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10101         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
10102         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
10103         int64_t ret_ref = 0;
10104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10106         return ret_ref;
10107 }
10108
10109 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
10110 CHECK(!owner->result_ok);
10111         return DecodeError_clone(&*owner->contents.err);
10112 }
10113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10114         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
10115         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10116         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
10117         int64_t ret_ref = tag_ptr(ret_copy, true);
10118         return ret_ref;
10119 }
10120
10121 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
10122         LDKUpdateAddHTLC ret = *owner->contents.result;
10123         ret.is_owned = false;
10124         return ret;
10125 }
10126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10127         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
10128         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
10129         int64_t ret_ref = 0;
10130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10132         return ret_ref;
10133 }
10134
10135 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
10136 CHECK(!owner->result_ok);
10137         return DecodeError_clone(&*owner->contents.err);
10138 }
10139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10140         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
10141         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10142         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
10143         int64_t ret_ref = tag_ptr(ret_copy, true);
10144         return ret_ref;
10145 }
10146
10147 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
10148         LDKOnionMessage ret = *owner->contents.result;
10149         ret.is_owned = false;
10150         return ret;
10151 }
10152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10153         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
10154         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
10155         int64_t ret_ref = 0;
10156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10158         return ret_ref;
10159 }
10160
10161 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
10162 CHECK(!owner->result_ok);
10163         return DecodeError_clone(&*owner->contents.err);
10164 }
10165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10166         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
10167         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10168         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
10169         int64_t ret_ref = tag_ptr(ret_copy, true);
10170         return ret_ref;
10171 }
10172
10173 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
10174         LDKPing ret = *owner->contents.result;
10175         ret.is_owned = false;
10176         return ret;
10177 }
10178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10179         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
10180         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
10181         int64_t ret_ref = 0;
10182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10183         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10184         return ret_ref;
10185 }
10186
10187 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
10188 CHECK(!owner->result_ok);
10189         return DecodeError_clone(&*owner->contents.err);
10190 }
10191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10192         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
10193         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10194         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
10195         int64_t ret_ref = tag_ptr(ret_copy, true);
10196         return ret_ref;
10197 }
10198
10199 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
10200         LDKPong ret = *owner->contents.result;
10201         ret.is_owned = false;
10202         return ret;
10203 }
10204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10205         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
10206         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
10207         int64_t ret_ref = 0;
10208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10210         return ret_ref;
10211 }
10212
10213 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
10214 CHECK(!owner->result_ok);
10215         return DecodeError_clone(&*owner->contents.err);
10216 }
10217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10218         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
10219         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10220         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
10221         int64_t ret_ref = tag_ptr(ret_copy, true);
10222         return ret_ref;
10223 }
10224
10225 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10226         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
10227         ret.is_owned = false;
10228         return ret;
10229 }
10230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10231         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10232         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10233         int64_t ret_ref = 0;
10234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10236         return ret_ref;
10237 }
10238
10239 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10240 CHECK(!owner->result_ok);
10241         return DecodeError_clone(&*owner->contents.err);
10242 }
10243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10244         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10245         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10246         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10247         int64_t ret_ref = tag_ptr(ret_copy, true);
10248         return ret_ref;
10249 }
10250
10251 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10252         LDKChannelAnnouncement ret = *owner->contents.result;
10253         ret.is_owned = false;
10254         return ret;
10255 }
10256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10257         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10258         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10259         int64_t ret_ref = 0;
10260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10262         return ret_ref;
10263 }
10264
10265 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10266 CHECK(!owner->result_ok);
10267         return DecodeError_clone(&*owner->contents.err);
10268 }
10269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10270         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10271         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10272         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10273         int64_t ret_ref = tag_ptr(ret_copy, true);
10274         return ret_ref;
10275 }
10276
10277 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10278         LDKUnsignedChannelUpdate ret = *owner->contents.result;
10279         ret.is_owned = false;
10280         return ret;
10281 }
10282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10283         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10284         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10285         int64_t ret_ref = 0;
10286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10288         return ret_ref;
10289 }
10290
10291 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10292 CHECK(!owner->result_ok);
10293         return DecodeError_clone(&*owner->contents.err);
10294 }
10295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10296         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10297         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10298         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
10299         int64_t ret_ref = tag_ptr(ret_copy, true);
10300         return ret_ref;
10301 }
10302
10303 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10304         LDKChannelUpdate ret = *owner->contents.result;
10305         ret.is_owned = false;
10306         return ret;
10307 }
10308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10309         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10310         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10311         int64_t ret_ref = 0;
10312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10314         return ret_ref;
10315 }
10316
10317 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10318 CHECK(!owner->result_ok);
10319         return DecodeError_clone(&*owner->contents.err);
10320 }
10321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10322         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10323         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10324         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
10325         int64_t ret_ref = tag_ptr(ret_copy, true);
10326         return ret_ref;
10327 }
10328
10329 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10330         LDKErrorMessage ret = *owner->contents.result;
10331         ret.is_owned = false;
10332         return ret;
10333 }
10334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10335         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10336         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
10337         int64_t ret_ref = 0;
10338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10340         return ret_ref;
10341 }
10342
10343 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10344 CHECK(!owner->result_ok);
10345         return DecodeError_clone(&*owner->contents.err);
10346 }
10347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10348         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10349         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10350         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
10351         int64_t ret_ref = tag_ptr(ret_copy, true);
10352         return ret_ref;
10353 }
10354
10355 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10356         LDKWarningMessage ret = *owner->contents.result;
10357         ret.is_owned = false;
10358         return ret;
10359 }
10360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10361         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10362         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
10363         int64_t ret_ref = 0;
10364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10366         return ret_ref;
10367 }
10368
10369 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10370 CHECK(!owner->result_ok);
10371         return DecodeError_clone(&*owner->contents.err);
10372 }
10373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10374         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10375         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10376         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
10377         int64_t ret_ref = tag_ptr(ret_copy, true);
10378         return ret_ref;
10379 }
10380
10381 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10382         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
10383         ret.is_owned = false;
10384         return ret;
10385 }
10386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10387         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10388         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10389         int64_t ret_ref = 0;
10390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10391         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10392         return ret_ref;
10393 }
10394
10395 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10396 CHECK(!owner->result_ok);
10397         return DecodeError_clone(&*owner->contents.err);
10398 }
10399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10400         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10401         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10402         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10403         int64_t ret_ref = tag_ptr(ret_copy, true);
10404         return ret_ref;
10405 }
10406
10407 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10408         LDKNodeAnnouncement ret = *owner->contents.result;
10409         ret.is_owned = false;
10410         return ret;
10411 }
10412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10413         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10414         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10415         int64_t ret_ref = 0;
10416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10418         return ret_ref;
10419 }
10420
10421 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10422 CHECK(!owner->result_ok);
10423         return DecodeError_clone(&*owner->contents.err);
10424 }
10425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10426         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10427         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10428         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10429         int64_t ret_ref = tag_ptr(ret_copy, true);
10430         return ret_ref;
10431 }
10432
10433 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10434         LDKQueryShortChannelIds ret = *owner->contents.result;
10435         ret.is_owned = false;
10436         return ret;
10437 }
10438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10439         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10440         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
10441         int64_t ret_ref = 0;
10442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10444         return ret_ref;
10445 }
10446
10447 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10448 CHECK(!owner->result_ok);
10449         return DecodeError_clone(&*owner->contents.err);
10450 }
10451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10452         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10453         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10454         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
10455         int64_t ret_ref = tag_ptr(ret_copy, true);
10456         return ret_ref;
10457 }
10458
10459 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10460         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
10461         ret.is_owned = false;
10462         return ret;
10463 }
10464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10465         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10466         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
10467         int64_t ret_ref = 0;
10468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10470         return ret_ref;
10471 }
10472
10473 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10474 CHECK(!owner->result_ok);
10475         return DecodeError_clone(&*owner->contents.err);
10476 }
10477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10478         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10479         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10480         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
10481         int64_t ret_ref = tag_ptr(ret_copy, true);
10482         return ret_ref;
10483 }
10484
10485 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10486         LDKQueryChannelRange ret = *owner->contents.result;
10487         ret.is_owned = false;
10488         return ret;
10489 }
10490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10491         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10492         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
10493         int64_t ret_ref = 0;
10494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10495         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10496         return ret_ref;
10497 }
10498
10499 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10500 CHECK(!owner->result_ok);
10501         return DecodeError_clone(&*owner->contents.err);
10502 }
10503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10504         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10505         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10506         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
10507         int64_t ret_ref = tag_ptr(ret_copy, true);
10508         return ret_ref;
10509 }
10510
10511 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10512         LDKReplyChannelRange ret = *owner->contents.result;
10513         ret.is_owned = false;
10514         return ret;
10515 }
10516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10517         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10518         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
10519         int64_t ret_ref = 0;
10520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10522         return ret_ref;
10523 }
10524
10525 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10526 CHECK(!owner->result_ok);
10527         return DecodeError_clone(&*owner->contents.err);
10528 }
10529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10530         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10531         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10532         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10533         int64_t ret_ref = tag_ptr(ret_copy, true);
10534         return ret_ref;
10535 }
10536
10537 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10538         LDKGossipTimestampFilter ret = *owner->contents.result;
10539         ret.is_owned = false;
10540         return ret;
10541 }
10542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10543         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10544         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10545         int64_t ret_ref = 0;
10546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10548         return ret_ref;
10549 }
10550
10551 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10552 CHECK(!owner->result_ok);
10553         return DecodeError_clone(&*owner->contents.err);
10554 }
10555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10556         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10557         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10558         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10559         int64_t ret_ref = tag_ptr(ret_copy, true);
10560         return ret_ref;
10561 }
10562
10563 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10564         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10565         for (size_t i = 0; i < ret.datalen; i++) {
10566                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10567         }
10568         return ret;
10569 }
10570 static jclass LDKSignOrCreationError_SignError_class = NULL;
10571 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10572 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10573 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10575         LDKSignOrCreationError_SignError_class =
10576                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10577         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10578         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10579         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10580         LDKSignOrCreationError_CreationError_class =
10581                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10582         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10583         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10584         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10585 }
10586 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10587         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
10588         switch(obj->tag) {
10589                 case LDKSignOrCreationError_SignError: {
10590                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10591                 }
10592                 case LDKSignOrCreationError_CreationError: {
10593                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10594                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10595                 }
10596                 default: abort();
10597         }
10598 }
10599 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10600         LDKInvoice ret = *owner->contents.result;
10601         ret.is_owned = false;
10602         return ret;
10603 }
10604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10605         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10606         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10607         int64_t ret_ref = 0;
10608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10610         return ret_ref;
10611 }
10612
10613 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10614 CHECK(!owner->result_ok);
10615         return SignOrCreationError_clone(&*owner->contents.err);
10616 }
10617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10618         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10619         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10620         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10621         int64_t ret_ref = tag_ptr(ret_copy, true);
10622         return ret_ref;
10623 }
10624
10625 typedef struct LDKFilter_JCalls {
10626         atomic_size_t refcnt;
10627         JavaVM *vm;
10628         jweak o;
10629         jmethodID register_tx_meth;
10630         jmethodID register_output_meth;
10631 } LDKFilter_JCalls;
10632 static void LDKFilter_JCalls_free(void* this_arg) {
10633         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10634         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10635                 JNIEnv *env;
10636                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10637                 if (get_jenv_res == JNI_EDETACHED) {
10638                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10639                 } else {
10640                         DO_ASSERT(get_jenv_res == JNI_OK);
10641                 }
10642                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10643                 if (get_jenv_res == JNI_EDETACHED) {
10644                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10645                 }
10646                 FREE(j_calls);
10647         }
10648 }
10649 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10650         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10651         JNIEnv *env;
10652         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10653         if (get_jenv_res == JNI_EDETACHED) {
10654                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10655         } else {
10656                 DO_ASSERT(get_jenv_res == JNI_OK);
10657         }
10658         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10659         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10660         LDKu8slice script_pubkey_var = script_pubkey;
10661         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10662         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10663         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10664         CHECK(obj != NULL);
10665         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10666         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10667                 (*env)->ExceptionDescribe(env);
10668                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10669         }
10670         if (get_jenv_res == JNI_EDETACHED) {
10671                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10672         }
10673 }
10674 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10675         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10676         JNIEnv *env;
10677         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10678         if (get_jenv_res == JNI_EDETACHED) {
10679                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10680         } else {
10681                 DO_ASSERT(get_jenv_res == JNI_OK);
10682         }
10683         LDKWatchedOutput output_var = output;
10684         int64_t output_ref = 0;
10685         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10686         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
10687         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10688         CHECK(obj != NULL);
10689         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
10690         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10691                 (*env)->ExceptionDescribe(env);
10692                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10693         }
10694         if (get_jenv_res == JNI_EDETACHED) {
10695                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10696         }
10697 }
10698 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10699         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10700         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10701 }
10702 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10703         jclass c = (*env)->GetObjectClass(env, o);
10704         CHECK(c != NULL);
10705         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10706         atomic_init(&calls->refcnt, 1);
10707         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10708         calls->o = (*env)->NewWeakGlobalRef(env, o);
10709         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10710         CHECK(calls->register_tx_meth != NULL);
10711         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
10712         CHECK(calls->register_output_meth != NULL);
10713
10714         LDKFilter ret = {
10715                 .this_arg = (void*) calls,
10716                 .register_tx = register_tx_LDKFilter_jcall,
10717                 .register_output = register_output_LDKFilter_jcall,
10718                 .free = LDKFilter_JCalls_free,
10719         };
10720         return ret;
10721 }
10722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10723         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10724         *res_ptr = LDKFilter_init(env, clz, o);
10725         return tag_ptr(res_ptr, true);
10726 }
10727 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) {
10728         void* this_arg_ptr = untag_ptr(this_arg);
10729         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10730         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10731         unsigned char txid_arr[32];
10732         CHECK((*env)->GetArrayLength(env, txid) == 32);
10733         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10734         unsigned char (*txid_ref)[32] = &txid_arr;
10735         LDKu8slice script_pubkey_ref;
10736         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10737         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10738         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10739         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10740 }
10741
10742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10743         void* this_arg_ptr = untag_ptr(this_arg);
10744         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10745         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10746         LDKWatchedOutput output_conv;
10747         output_conv.inner = untag_ptr(output);
10748         output_conv.is_owned = ptr_is_owned(output);
10749         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10750         output_conv = WatchedOutput_clone(&output_conv);
10751         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10752 }
10753
10754 static jclass LDKCOption_FilterZ_Some_class = NULL;
10755 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10756 static jclass LDKCOption_FilterZ_None_class = NULL;
10757 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10759         LDKCOption_FilterZ_Some_class =
10760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10761         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10762         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10763         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10764         LDKCOption_FilterZ_None_class =
10765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10766         CHECK(LDKCOption_FilterZ_None_class != NULL);
10767         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10768         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10769 }
10770 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10771         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
10772         switch(obj->tag) {
10773                 case LDKCOption_FilterZ_Some: {
10774                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10775                         *some_ret = obj->some;
10776                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10777                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10778                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10779                                 LDKFilter_JCalls_cloned(&(*some_ret));
10780                         }
10781                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
10782                 }
10783                 case LDKCOption_FilterZ_None: {
10784                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10785                 }
10786                 default: abort();
10787         }
10788 }
10789 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10790         LDKLockedChannelMonitor ret = *owner->contents.result;
10791         ret.is_owned = false;
10792         return ret;
10793 }
10794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10795         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10796         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10797         int64_t ret_ref = 0;
10798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10799         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10800         return ret_ref;
10801 }
10802
10803 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10804 CHECK(!owner->result_ok);
10805         return *owner->contents.err;
10806 }
10807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10808         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10809         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10810 }
10811
10812 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10813         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10814         for (size_t i = 0; i < ret.datalen; i++) {
10815                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10816         }
10817         return ret;
10818 }
10819 static inline LDKCVec_MonitorUpdateIdZ CVec_MonitorUpdateIdZ_clone(const LDKCVec_MonitorUpdateIdZ *orig) {
10820         LDKCVec_MonitorUpdateIdZ ret = { .data = MALLOC(sizeof(LDKMonitorUpdateId) * orig->datalen, "LDKCVec_MonitorUpdateIdZ clone bytes"), .datalen = orig->datalen };
10821         for (size_t i = 0; i < ret.datalen; i++) {
10822                 ret.data[i] = MonitorUpdateId_clone(&orig->data[i]);
10823         }
10824         return ret;
10825 }
10826 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
10827         LDKOutPoint ret = owner->a;
10828         ret.is_owned = false;
10829         return ret;
10830 }
10831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
10832         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
10833         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(owner_conv);
10834         int64_t ret_ref = 0;
10835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10837         return ret_ref;
10838 }
10839
10840 static inline struct LDKCVec_MonitorUpdateIdZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
10841         return CVec_MonitorUpdateIdZ_clone(&owner->b);
10842 }
10843 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
10844         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
10845         LDKCVec_MonitorUpdateIdZ ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(owner_conv);
10846         int64_tArray ret_arr = NULL;
10847         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10848         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10849         for (size_t r = 0; r < ret_var.datalen; r++) {
10850                 LDKMonitorUpdateId ret_conv_17_var = ret_var.data[r];
10851                 int64_t ret_conv_17_ref = 0;
10852                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_17_var);
10853                 ret_conv_17_ref = tag_ptr(ret_conv_17_var.inner, ret_conv_17_var.is_owned);
10854                 ret_arr_ptr[r] = ret_conv_17_ref;
10855         }
10856         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10857         FREE(ret_var.data);
10858         return ret_arr;
10859 }
10860
10861 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ *orig) {
10862         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ clone bytes"), .datalen = orig->datalen };
10863         for (size_t i = 0; i < ret.datalen; i++) {
10864                 ret.data[i] = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(&orig->data[i]);
10865         }
10866         return ret;
10867 }
10868 typedef struct LDKMessageSendEventsProvider_JCalls {
10869         atomic_size_t refcnt;
10870         JavaVM *vm;
10871         jweak o;
10872         jmethodID get_and_clear_pending_msg_events_meth;
10873 } LDKMessageSendEventsProvider_JCalls;
10874 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10875         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10876         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10877                 JNIEnv *env;
10878                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10879                 if (get_jenv_res == JNI_EDETACHED) {
10880                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10881                 } else {
10882                         DO_ASSERT(get_jenv_res == JNI_OK);
10883                 }
10884                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10885                 if (get_jenv_res == JNI_EDETACHED) {
10886                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10887                 }
10888                 FREE(j_calls);
10889         }
10890 }
10891 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10892         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10893         JNIEnv *env;
10894         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10895         if (get_jenv_res == JNI_EDETACHED) {
10896                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10897         } else {
10898                 DO_ASSERT(get_jenv_res == JNI_OK);
10899         }
10900         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10901         CHECK(obj != NULL);
10902         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10903         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10904                 (*env)->ExceptionDescribe(env);
10905                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10906         }
10907         LDKCVec_MessageSendEventZ ret_constr;
10908         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10909         if (ret_constr.datalen > 0)
10910                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10911         else
10912                 ret_constr.data = NULL;
10913         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10914         for (size_t s = 0; s < ret_constr.datalen; s++) {
10915                 int64_t ret_conv_18 = ret_vals[s];
10916                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
10917                 CHECK_ACCESS(ret_conv_18_ptr);
10918                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10919                 FREE(untag_ptr(ret_conv_18));
10920                 ret_constr.data[s] = ret_conv_18_conv;
10921         }
10922         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10923         if (get_jenv_res == JNI_EDETACHED) {
10924                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10925         }
10926         return ret_constr;
10927 }
10928 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10929         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10930         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10931 }
10932 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10933         jclass c = (*env)->GetObjectClass(env, o);
10934         CHECK(c != NULL);
10935         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10936         atomic_init(&calls->refcnt, 1);
10937         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10938         calls->o = (*env)->NewWeakGlobalRef(env, o);
10939         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10940         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10941
10942         LDKMessageSendEventsProvider ret = {
10943                 .this_arg = (void*) calls,
10944                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10945                 .free = LDKMessageSendEventsProvider_JCalls_free,
10946         };
10947         return ret;
10948 }
10949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10950         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10951         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10952         return tag_ptr(res_ptr, true);
10953 }
10954 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10955         void* this_arg_ptr = untag_ptr(this_arg);
10956         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10957         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10958         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10959         int64_tArray ret_arr = NULL;
10960         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10961         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10962         for (size_t s = 0; s < ret_var.datalen; s++) {
10963                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10964                 *ret_conv_18_copy = ret_var.data[s];
10965                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
10966                 ret_arr_ptr[s] = ret_conv_18_ref;
10967         }
10968         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10969         FREE(ret_var.data);
10970         return ret_arr;
10971 }
10972
10973 typedef struct LDKOnionMessageProvider_JCalls {
10974         atomic_size_t refcnt;
10975         JavaVM *vm;
10976         jweak o;
10977         jmethodID next_onion_message_for_peer_meth;
10978 } LDKOnionMessageProvider_JCalls;
10979 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
10980         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10981         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10982                 JNIEnv *env;
10983                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10984                 if (get_jenv_res == JNI_EDETACHED) {
10985                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10986                 } else {
10987                         DO_ASSERT(get_jenv_res == JNI_OK);
10988                 }
10989                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10990                 if (get_jenv_res == JNI_EDETACHED) {
10991                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10992                 }
10993                 FREE(j_calls);
10994         }
10995 }
10996 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
10997         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10998         JNIEnv *env;
10999         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11000         if (get_jenv_res == JNI_EDETACHED) {
11001                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11002         } else {
11003                 DO_ASSERT(get_jenv_res == JNI_OK);
11004         }
11005         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
11006         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
11007         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11008         CHECK(obj != NULL);
11009         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
11010         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11011                 (*env)->ExceptionDescribe(env);
11012                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
11013         }
11014         LDKOnionMessage ret_conv;
11015         ret_conv.inner = untag_ptr(ret);
11016         ret_conv.is_owned = ptr_is_owned(ret);
11017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
11018         if (get_jenv_res == JNI_EDETACHED) {
11019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11020         }
11021         return ret_conv;
11022 }
11023 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
11024         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
11025         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11026 }
11027 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
11028         jclass c = (*env)->GetObjectClass(env, o);
11029         CHECK(c != NULL);
11030         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
11031         atomic_init(&calls->refcnt, 1);
11032         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11033         calls->o = (*env)->NewWeakGlobalRef(env, o);
11034         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
11035         CHECK(calls->next_onion_message_for_peer_meth != NULL);
11036
11037         LDKOnionMessageProvider ret = {
11038                 .this_arg = (void*) calls,
11039                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
11040                 .free = LDKOnionMessageProvider_JCalls_free,
11041         };
11042         return ret;
11043 }
11044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
11045         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
11046         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
11047         return tag_ptr(res_ptr, true);
11048 }
11049 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) {
11050         void* this_arg_ptr = untag_ptr(this_arg);
11051         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11052         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
11053         LDKPublicKey peer_node_id_ref;
11054         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
11055         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
11056         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
11057         int64_t ret_ref = 0;
11058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11059         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11060         return ret_ref;
11061 }
11062
11063 typedef struct LDKEventHandler_JCalls {
11064         atomic_size_t refcnt;
11065         JavaVM *vm;
11066         jweak o;
11067         jmethodID handle_event_meth;
11068 } LDKEventHandler_JCalls;
11069 static void LDKEventHandler_JCalls_free(void* this_arg) {
11070         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
11071         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11072                 JNIEnv *env;
11073                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11074                 if (get_jenv_res == JNI_EDETACHED) {
11075                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11076                 } else {
11077                         DO_ASSERT(get_jenv_res == JNI_OK);
11078                 }
11079                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11080                 if (get_jenv_res == JNI_EDETACHED) {
11081                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11082                 }
11083                 FREE(j_calls);
11084         }
11085 }
11086 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
11087         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
11088         JNIEnv *env;
11089         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11090         if (get_jenv_res == JNI_EDETACHED) {
11091                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11092         } else {
11093                 DO_ASSERT(get_jenv_res == JNI_OK);
11094         }
11095         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11096         *event_copy = event;
11097         int64_t event_ref = tag_ptr(event_copy, true);
11098         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11099         CHECK(obj != NULL);
11100         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
11101         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11102                 (*env)->ExceptionDescribe(env);
11103                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
11104         }
11105         if (get_jenv_res == JNI_EDETACHED) {
11106                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11107         }
11108 }
11109 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
11110         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
11111         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11112 }
11113 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
11114         jclass c = (*env)->GetObjectClass(env, o);
11115         CHECK(c != NULL);
11116         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
11117         atomic_init(&calls->refcnt, 1);
11118         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11119         calls->o = (*env)->NewWeakGlobalRef(env, o);
11120         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
11121         CHECK(calls->handle_event_meth != NULL);
11122
11123         LDKEventHandler ret = {
11124                 .this_arg = (void*) calls,
11125                 .handle_event = handle_event_LDKEventHandler_jcall,
11126                 .free = LDKEventHandler_JCalls_free,
11127         };
11128         return ret;
11129 }
11130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
11131         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
11132         *res_ptr = LDKEventHandler_init(env, clz, o);
11133         return tag_ptr(res_ptr, true);
11134 }
11135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
11136         void* this_arg_ptr = untag_ptr(this_arg);
11137         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11138         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
11139         void* event_ptr = untag_ptr(event);
11140         CHECK_ACCESS(event_ptr);
11141         LDKEvent event_conv = *(LDKEvent*)(event_ptr);
11142         event_conv = Event_clone((LDKEvent*)untag_ptr(event));
11143         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
11144 }
11145
11146 typedef struct LDKEventsProvider_JCalls {
11147         atomic_size_t refcnt;
11148         JavaVM *vm;
11149         jweak o;
11150         jmethodID process_pending_events_meth;
11151 } LDKEventsProvider_JCalls;
11152 static void LDKEventsProvider_JCalls_free(void* this_arg) {
11153         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
11154         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11155                 JNIEnv *env;
11156                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11157                 if (get_jenv_res == JNI_EDETACHED) {
11158                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11159                 } else {
11160                         DO_ASSERT(get_jenv_res == JNI_OK);
11161                 }
11162                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11163                 if (get_jenv_res == JNI_EDETACHED) {
11164                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11165                 }
11166                 FREE(j_calls);
11167         }
11168 }
11169 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
11170         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
11171         JNIEnv *env;
11172         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11173         if (get_jenv_res == JNI_EDETACHED) {
11174                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11175         } else {
11176                 DO_ASSERT(get_jenv_res == JNI_OK);
11177         }
11178         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
11179         *handler_ret = handler;
11180         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11181         CHECK(obj != NULL);
11182         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
11183         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11184                 (*env)->ExceptionDescribe(env);
11185                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
11186         }
11187         if (get_jenv_res == JNI_EDETACHED) {
11188                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11189         }
11190 }
11191 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
11192         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
11193         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11194 }
11195 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
11196         jclass c = (*env)->GetObjectClass(env, o);
11197         CHECK(c != NULL);
11198         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
11199         atomic_init(&calls->refcnt, 1);
11200         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11201         calls->o = (*env)->NewWeakGlobalRef(env, o);
11202         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
11203         CHECK(calls->process_pending_events_meth != NULL);
11204
11205         LDKEventsProvider ret = {
11206                 .this_arg = (void*) calls,
11207                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
11208                 .free = LDKEventsProvider_JCalls_free,
11209         };
11210         return ret;
11211 }
11212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
11213         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11214         *res_ptr = LDKEventsProvider_init(env, clz, o);
11215         return tag_ptr(res_ptr, true);
11216 }
11217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
11218         void* this_arg_ptr = untag_ptr(this_arg);
11219         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11220         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
11221         void* handler_ptr = untag_ptr(handler);
11222         CHECK_ACCESS(handler_ptr);
11223         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
11224         if (handler_conv.free == LDKEventHandler_JCalls_free) {
11225                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11226                 LDKEventHandler_JCalls_cloned(&handler_conv);
11227         }
11228         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
11229 }
11230
11231 typedef struct LDKPersister_JCalls {
11232         atomic_size_t refcnt;
11233         JavaVM *vm;
11234         jweak o;
11235         jmethodID persist_manager_meth;
11236         jmethodID persist_graph_meth;
11237         jmethodID persist_scorer_meth;
11238 } LDKPersister_JCalls;
11239 static void LDKPersister_JCalls_free(void* this_arg) {
11240         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11241         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11242                 JNIEnv *env;
11243                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11244                 if (get_jenv_res == JNI_EDETACHED) {
11245                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11246                 } else {
11247                         DO_ASSERT(get_jenv_res == JNI_OK);
11248                 }
11249                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11250                 if (get_jenv_res == JNI_EDETACHED) {
11251                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11252                 }
11253                 FREE(j_calls);
11254         }
11255 }
11256 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
11257         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11258         JNIEnv *env;
11259         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11260         if (get_jenv_res == JNI_EDETACHED) {
11261                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11262         } else {
11263                 DO_ASSERT(get_jenv_res == JNI_OK);
11264         }
11265         LDKChannelManager channel_manager_var = *channel_manager;
11266         int64_t channel_manager_ref = 0;
11267         // WARNING: we may need a move here but no clone is available for LDKChannelManager
11268         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11269         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
11270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11271         CHECK(obj != NULL);
11272         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11273         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11274                 (*env)->ExceptionDescribe(env);
11275                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11276         }
11277         void* ret_ptr = untag_ptr(ret);
11278         CHECK_ACCESS(ret_ptr);
11279         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11280         FREE(untag_ptr(ret));
11281         if (get_jenv_res == JNI_EDETACHED) {
11282                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11283         }
11284         return ret_conv;
11285 }
11286 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
11287         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11288         JNIEnv *env;
11289         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11290         if (get_jenv_res == JNI_EDETACHED) {
11291                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11292         } else {
11293                 DO_ASSERT(get_jenv_res == JNI_OK);
11294         }
11295         LDKNetworkGraph network_graph_var = *network_graph;
11296         int64_t network_graph_ref = 0;
11297         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
11298         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
11299         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
11300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11301         CHECK(obj != NULL);
11302         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
11303         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11304                 (*env)->ExceptionDescribe(env);
11305                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
11306         }
11307         void* ret_ptr = untag_ptr(ret);
11308         CHECK_ACCESS(ret_ptr);
11309         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11310         FREE(untag_ptr(ret));
11311         if (get_jenv_res == JNI_EDETACHED) {
11312                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11313         }
11314         return ret_conv;
11315 }
11316 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
11317         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11318         JNIEnv *env;
11319         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11320         if (get_jenv_res == JNI_EDETACHED) {
11321                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11322         } else {
11323                 DO_ASSERT(get_jenv_res == JNI_OK);
11324         }
11325         // WARNING: This object doesn't live past this scope, needs clone!
11326         int64_t ret_scorer = tag_ptr(scorer, false);
11327         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11328         CHECK(obj != NULL);
11329         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
11330         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11331                 (*env)->ExceptionDescribe(env);
11332                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
11333         }
11334         void* ret_ptr = untag_ptr(ret);
11335         CHECK_ACCESS(ret_ptr);
11336         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11337         FREE(untag_ptr(ret));
11338         if (get_jenv_res == JNI_EDETACHED) {
11339                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11340         }
11341         return ret_conv;
11342 }
11343 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
11344         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
11345         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11346 }
11347 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
11348         jclass c = (*env)->GetObjectClass(env, o);
11349         CHECK(c != NULL);
11350         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
11351         atomic_init(&calls->refcnt, 1);
11352         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11353         calls->o = (*env)->NewWeakGlobalRef(env, o);
11354         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11355         CHECK(calls->persist_manager_meth != NULL);
11356         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
11357         CHECK(calls->persist_graph_meth != NULL);
11358         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
11359         CHECK(calls->persist_scorer_meth != NULL);
11360
11361         LDKPersister ret = {
11362                 .this_arg = (void*) calls,
11363                 .persist_manager = persist_manager_LDKPersister_jcall,
11364                 .persist_graph = persist_graph_LDKPersister_jcall,
11365                 .persist_scorer = persist_scorer_LDKPersister_jcall,
11366                 .free = LDKPersister_JCalls_free,
11367         };
11368         return ret;
11369 }
11370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11371         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
11372         *res_ptr = LDKPersister_init(env, clz, o);
11373         return tag_ptr(res_ptr, true);
11374 }
11375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11376         void* this_arg_ptr = untag_ptr(this_arg);
11377         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11378         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11379         LDKChannelManager channel_manager_conv;
11380         channel_manager_conv.inner = untag_ptr(channel_manager);
11381         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
11382         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
11383         channel_manager_conv.is_owned = false;
11384         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11385         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11386         return tag_ptr(ret_conv, true);
11387 }
11388
11389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
11390         void* this_arg_ptr = untag_ptr(this_arg);
11391         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11392         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11393         LDKNetworkGraph network_graph_conv;
11394         network_graph_conv.inner = untag_ptr(network_graph);
11395         network_graph_conv.is_owned = ptr_is_owned(network_graph);
11396         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
11397         network_graph_conv.is_owned = false;
11398         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11399         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
11400         return tag_ptr(ret_conv, true);
11401 }
11402
11403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
11404         void* this_arg_ptr = untag_ptr(this_arg);
11405         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11406         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11407         void* scorer_ptr = untag_ptr(scorer);
11408         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
11409         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
11410         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11411         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
11412         return tag_ptr(ret_conv, true);
11413 }
11414
11415 typedef struct LDKFutureCallback_JCalls {
11416         atomic_size_t refcnt;
11417         JavaVM *vm;
11418         jweak o;
11419         jmethodID call_meth;
11420 } LDKFutureCallback_JCalls;
11421 static void LDKFutureCallback_JCalls_free(void* this_arg) {
11422         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11423         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11424                 JNIEnv *env;
11425                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11426                 if (get_jenv_res == JNI_EDETACHED) {
11427                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11428                 } else {
11429                         DO_ASSERT(get_jenv_res == JNI_OK);
11430                 }
11431                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11432                 if (get_jenv_res == JNI_EDETACHED) {
11433                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11434                 }
11435                 FREE(j_calls);
11436         }
11437 }
11438 void call_LDKFutureCallback_jcall(const void* this_arg) {
11439         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11440         JNIEnv *env;
11441         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11442         if (get_jenv_res == JNI_EDETACHED) {
11443                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11444         } else {
11445                 DO_ASSERT(get_jenv_res == JNI_OK);
11446         }
11447         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11448         CHECK(obj != NULL);
11449         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
11450         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11451                 (*env)->ExceptionDescribe(env);
11452                 (*env)->FatalError(env, "A call to call in LDKFutureCallback from rust threw an exception.");
11453         }
11454         if (get_jenv_res == JNI_EDETACHED) {
11455                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11456         }
11457 }
11458 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
11459         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
11460         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11461 }
11462 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
11463         jclass c = (*env)->GetObjectClass(env, o);
11464         CHECK(c != NULL);
11465         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
11466         atomic_init(&calls->refcnt, 1);
11467         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11468         calls->o = (*env)->NewWeakGlobalRef(env, o);
11469         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
11470         CHECK(calls->call_meth != NULL);
11471
11472         LDKFutureCallback ret = {
11473                 .this_arg = (void*) calls,
11474                 .call = call_LDKFutureCallback_jcall,
11475                 .free = LDKFutureCallback_JCalls_free,
11476         };
11477         return ret;
11478 }
11479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
11480         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
11481         *res_ptr = LDKFutureCallback_init(env, clz, o);
11482         return tag_ptr(res_ptr, true);
11483 }
11484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
11485         void* this_arg_ptr = untag_ptr(this_arg);
11486         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11487         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
11488         (this_arg_conv->call)(this_arg_conv->this_arg);
11489 }
11490
11491 typedef struct LDKListen_JCalls {
11492         atomic_size_t refcnt;
11493         JavaVM *vm;
11494         jweak o;
11495         jmethodID filtered_block_connected_meth;
11496         jmethodID block_connected_meth;
11497         jmethodID block_disconnected_meth;
11498 } LDKListen_JCalls;
11499 static void LDKListen_JCalls_free(void* this_arg) {
11500         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11501         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11502                 JNIEnv *env;
11503                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11504                 if (get_jenv_res == JNI_EDETACHED) {
11505                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11506                 } else {
11507                         DO_ASSERT(get_jenv_res == JNI_OK);
11508                 }
11509                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11510                 if (get_jenv_res == JNI_EDETACHED) {
11511                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11512                 }
11513                 FREE(j_calls);
11514         }
11515 }
11516 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11517         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11518         JNIEnv *env;
11519         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11520         if (get_jenv_res == JNI_EDETACHED) {
11521                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11522         } else {
11523                 DO_ASSERT(get_jenv_res == JNI_OK);
11524         }
11525         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11526         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11527         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11528         int64_tArray txdata_arr = NULL;
11529         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11530         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11531         for (size_t c = 0; c < txdata_var.datalen; c++) {
11532                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11533                 *txdata_conv_28_conv = txdata_var.data[c];
11534                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11535         }
11536         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11537         FREE(txdata_var.data);
11538         int32_t height_conv = height;
11539         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11540         CHECK(obj != NULL);
11541         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11542         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11543                 (*env)->ExceptionDescribe(env);
11544                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11545         }
11546         if (get_jenv_res == JNI_EDETACHED) {
11547                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11548         }
11549 }
11550 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11551         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11552         JNIEnv *env;
11553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11554         if (get_jenv_res == JNI_EDETACHED) {
11555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11556         } else {
11557                 DO_ASSERT(get_jenv_res == JNI_OK);
11558         }
11559         LDKu8slice block_var = block;
11560         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11561         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11562         int32_t height_conv = height;
11563         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11564         CHECK(obj != NULL);
11565         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11566         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11567                 (*env)->ExceptionDescribe(env);
11568                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11569         }
11570         if (get_jenv_res == JNI_EDETACHED) {
11571                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11572         }
11573 }
11574 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11575         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11576         JNIEnv *env;
11577         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11578         if (get_jenv_res == JNI_EDETACHED) {
11579                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11580         } else {
11581                 DO_ASSERT(get_jenv_res == JNI_OK);
11582         }
11583         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11584         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11585         int32_t height_conv = height;
11586         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11587         CHECK(obj != NULL);
11588         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11589         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11590                 (*env)->ExceptionDescribe(env);
11591                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11592         }
11593         if (get_jenv_res == JNI_EDETACHED) {
11594                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11595         }
11596 }
11597 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11598         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11599         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11600 }
11601 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11602         jclass c = (*env)->GetObjectClass(env, o);
11603         CHECK(c != NULL);
11604         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11605         atomic_init(&calls->refcnt, 1);
11606         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11607         calls->o = (*env)->NewWeakGlobalRef(env, o);
11608         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11609         CHECK(calls->filtered_block_connected_meth != NULL);
11610         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11611         CHECK(calls->block_connected_meth != NULL);
11612         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11613         CHECK(calls->block_disconnected_meth != NULL);
11614
11615         LDKListen ret = {
11616                 .this_arg = (void*) calls,
11617                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11618                 .block_connected = block_connected_LDKListen_jcall,
11619                 .block_disconnected = block_disconnected_LDKListen_jcall,
11620                 .free = LDKListen_JCalls_free,
11621         };
11622         return ret;
11623 }
11624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11625         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11626         *res_ptr = LDKListen_init(env, clz, o);
11627         return tag_ptr(res_ptr, true);
11628 }
11629 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) {
11630         void* this_arg_ptr = untag_ptr(this_arg);
11631         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11632         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11633         unsigned char header_arr[80];
11634         CHECK((*env)->GetArrayLength(env, header) == 80);
11635         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11636         unsigned char (*header_ref)[80] = &header_arr;
11637         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11638         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11639         if (txdata_constr.datalen > 0)
11640                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11641         else
11642                 txdata_constr.data = NULL;
11643         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11644         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11645                 int64_t txdata_conv_28 = txdata_vals[c];
11646                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11647                 CHECK_ACCESS(txdata_conv_28_ptr);
11648                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11649                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11650                 txdata_constr.data[c] = txdata_conv_28_conv;
11651         }
11652         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11653         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11654 }
11655
11656 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) {
11657         void* this_arg_ptr = untag_ptr(this_arg);
11658         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11659         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11660         LDKu8slice block_ref;
11661         block_ref.datalen = (*env)->GetArrayLength(env, block);
11662         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11663         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11664         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11665 }
11666
11667 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) {
11668         void* this_arg_ptr = untag_ptr(this_arg);
11669         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11670         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11671         unsigned char header_arr[80];
11672         CHECK((*env)->GetArrayLength(env, header) == 80);
11673         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11674         unsigned char (*header_ref)[80] = &header_arr;
11675         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11676 }
11677
11678 typedef struct LDKConfirm_JCalls {
11679         atomic_size_t refcnt;
11680         JavaVM *vm;
11681         jweak o;
11682         jmethodID transactions_confirmed_meth;
11683         jmethodID transaction_unconfirmed_meth;
11684         jmethodID best_block_updated_meth;
11685         jmethodID get_relevant_txids_meth;
11686 } LDKConfirm_JCalls;
11687 static void LDKConfirm_JCalls_free(void* this_arg) {
11688         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11689         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11690                 JNIEnv *env;
11691                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11692                 if (get_jenv_res == JNI_EDETACHED) {
11693                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11694                 } else {
11695                         DO_ASSERT(get_jenv_res == JNI_OK);
11696                 }
11697                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11698                 if (get_jenv_res == JNI_EDETACHED) {
11699                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11700                 }
11701                 FREE(j_calls);
11702         }
11703 }
11704 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11705         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11706         JNIEnv *env;
11707         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11708         if (get_jenv_res == JNI_EDETACHED) {
11709                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11710         } else {
11711                 DO_ASSERT(get_jenv_res == JNI_OK);
11712         }
11713         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11714         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11715         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11716         int64_tArray txdata_arr = NULL;
11717         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11718         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11719         for (size_t c = 0; c < txdata_var.datalen; c++) {
11720                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11721                 *txdata_conv_28_conv = txdata_var.data[c];
11722                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11723         }
11724         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11725         FREE(txdata_var.data);
11726         int32_t height_conv = height;
11727         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11728         CHECK(obj != NULL);
11729         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11730         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11731                 (*env)->ExceptionDescribe(env);
11732                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11733         }
11734         if (get_jenv_res == JNI_EDETACHED) {
11735                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11736         }
11737 }
11738 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11739         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11740         JNIEnv *env;
11741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11742         if (get_jenv_res == JNI_EDETACHED) {
11743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11744         } else {
11745                 DO_ASSERT(get_jenv_res == JNI_OK);
11746         }
11747         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11748         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11749         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11750         CHECK(obj != NULL);
11751         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11752         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11753                 (*env)->ExceptionDescribe(env);
11754                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11755         }
11756         if (get_jenv_res == JNI_EDETACHED) {
11757                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11758         }
11759 }
11760 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11761         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11762         JNIEnv *env;
11763         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11764         if (get_jenv_res == JNI_EDETACHED) {
11765                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11766         } else {
11767                 DO_ASSERT(get_jenv_res == JNI_OK);
11768         }
11769         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11770         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11771         int32_t height_conv = height;
11772         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11773         CHECK(obj != NULL);
11774         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11775         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11776                 (*env)->ExceptionDescribe(env);
11777                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11778         }
11779         if (get_jenv_res == JNI_EDETACHED) {
11780                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11781         }
11782 }
11783 LDKCVec_C2Tuple_TxidBlockHashZZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11784         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11785         JNIEnv *env;
11786         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11787         if (get_jenv_res == JNI_EDETACHED) {
11788                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11789         } else {
11790                 DO_ASSERT(get_jenv_res == JNI_OK);
11791         }
11792         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11793         CHECK(obj != NULL);
11794         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11795         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11796                 (*env)->ExceptionDescribe(env);
11797                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11798         }
11799         LDKCVec_C2Tuple_TxidBlockHashZZ ret_constr;
11800         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11801         if (ret_constr.datalen > 0)
11802                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
11803         else
11804                 ret_constr.data = NULL;
11805         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11806         for (size_t z = 0; z < ret_constr.datalen; z++) {
11807                 int64_t ret_conv_25 = ret_vals[z];
11808                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
11809                 CHECK_ACCESS(ret_conv_25_ptr);
11810                 LDKC2Tuple_TxidBlockHashZ ret_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(ret_conv_25_ptr);
11811                 FREE(untag_ptr(ret_conv_25));
11812                 ret_constr.data[z] = ret_conv_25_conv;
11813         }
11814         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11815         if (get_jenv_res == JNI_EDETACHED) {
11816                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11817         }
11818         return ret_constr;
11819 }
11820 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11821         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11822         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11823 }
11824 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11825         jclass c = (*env)->GetObjectClass(env, o);
11826         CHECK(c != NULL);
11827         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11828         atomic_init(&calls->refcnt, 1);
11829         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11830         calls->o = (*env)->NewWeakGlobalRef(env, o);
11831         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11832         CHECK(calls->transactions_confirmed_meth != NULL);
11833         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11834         CHECK(calls->transaction_unconfirmed_meth != NULL);
11835         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11836         CHECK(calls->best_block_updated_meth != NULL);
11837         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[J");
11838         CHECK(calls->get_relevant_txids_meth != NULL);
11839
11840         LDKConfirm ret = {
11841                 .this_arg = (void*) calls,
11842                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11843                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11844                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11845                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11846                 .free = LDKConfirm_JCalls_free,
11847         };
11848         return ret;
11849 }
11850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11851         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11852         *res_ptr = LDKConfirm_init(env, clz, o);
11853         return tag_ptr(res_ptr, true);
11854 }
11855 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) {
11856         void* this_arg_ptr = untag_ptr(this_arg);
11857         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11858         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11859         unsigned char header_arr[80];
11860         CHECK((*env)->GetArrayLength(env, header) == 80);
11861         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11862         unsigned char (*header_ref)[80] = &header_arr;
11863         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11864         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11865         if (txdata_constr.datalen > 0)
11866                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11867         else
11868                 txdata_constr.data = NULL;
11869         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11870         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11871                 int64_t txdata_conv_28 = txdata_vals[c];
11872                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11873                 CHECK_ACCESS(txdata_conv_28_ptr);
11874                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11875                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11876                 txdata_constr.data[c] = txdata_conv_28_conv;
11877         }
11878         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11879         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11880 }
11881
11882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11883         void* this_arg_ptr = untag_ptr(this_arg);
11884         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11885         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11886         unsigned char txid_arr[32];
11887         CHECK((*env)->GetArrayLength(env, txid) == 32);
11888         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11889         unsigned char (*txid_ref)[32] = &txid_arr;
11890         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11891 }
11892
11893 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) {
11894         void* this_arg_ptr = untag_ptr(this_arg);
11895         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11896         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11897         unsigned char header_arr[80];
11898         CHECK((*env)->GetArrayLength(env, header) == 80);
11899         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11900         unsigned char (*header_ref)[80] = &header_arr;
11901         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11902 }
11903
11904 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11905         void* this_arg_ptr = untag_ptr(this_arg);
11906         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11907         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11908         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11909         int64_tArray ret_arr = NULL;
11910         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11911         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11912         for (size_t z = 0; z < ret_var.datalen; z++) {
11913                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
11914                 *ret_conv_25_conv = ret_var.data[z];
11915                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
11916         }
11917         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11918         FREE(ret_var.data);
11919         return ret_arr;
11920 }
11921
11922 typedef struct LDKPersist_JCalls {
11923         atomic_size_t refcnt;
11924         JavaVM *vm;
11925         jweak o;
11926         jmethodID persist_new_channel_meth;
11927         jmethodID update_persisted_channel_meth;
11928 } LDKPersist_JCalls;
11929 static void LDKPersist_JCalls_free(void* this_arg) {
11930         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11931         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11932                 JNIEnv *env;
11933                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11934                 if (get_jenv_res == JNI_EDETACHED) {
11935                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11936                 } else {
11937                         DO_ASSERT(get_jenv_res == JNI_OK);
11938                 }
11939                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11940                 if (get_jenv_res == JNI_EDETACHED) {
11941                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11942                 }
11943                 FREE(j_calls);
11944         }
11945 }
11946 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11947         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11948         JNIEnv *env;
11949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11950         if (get_jenv_res == JNI_EDETACHED) {
11951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11952         } else {
11953                 DO_ASSERT(get_jenv_res == JNI_OK);
11954         }
11955         LDKOutPoint channel_id_var = channel_id;
11956         int64_t channel_id_ref = 0;
11957         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11958         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11959         LDKChannelMonitor data_var = *data;
11960         int64_t data_ref = 0;
11961         data_var = ChannelMonitor_clone(&data_var);
11962         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11963         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11964         LDKMonitorUpdateId update_id_var = update_id;
11965         int64_t update_id_ref = 0;
11966         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11967         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11968         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11969         CHECK(obj != NULL);
11970         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11971         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11972                 (*env)->ExceptionDescribe(env);
11973                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11974         }
11975         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
11976         if (get_jenv_res == JNI_EDETACHED) {
11977                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11978         }
11979         return ret_conv;
11980 }
11981 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11982         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11983         JNIEnv *env;
11984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11985         if (get_jenv_res == JNI_EDETACHED) {
11986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11987         } else {
11988                 DO_ASSERT(get_jenv_res == JNI_OK);
11989         }
11990         LDKOutPoint channel_id_var = channel_id;
11991         int64_t channel_id_ref = 0;
11992         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11993         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11994         LDKChannelMonitorUpdate update_var = *update;
11995         int64_t update_ref = 0;
11996         update_var = ChannelMonitorUpdate_clone(&update_var);
11997         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11998         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
11999         LDKChannelMonitor data_var = *data;
12000         int64_t data_ref = 0;
12001         data_var = ChannelMonitor_clone(&data_var);
12002         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12003         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12004         LDKMonitorUpdateId update_id_var = update_id;
12005         int64_t update_id_ref = 0;
12006         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12007         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12008         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12009         CHECK(obj != NULL);
12010         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
12011         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12012                 (*env)->ExceptionDescribe(env);
12013                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
12014         }
12015         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12016         if (get_jenv_res == JNI_EDETACHED) {
12017                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12018         }
12019         return ret_conv;
12020 }
12021 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
12022         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
12023         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12024 }
12025 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
12026         jclass c = (*env)->GetObjectClass(env, o);
12027         CHECK(c != NULL);
12028         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
12029         atomic_init(&calls->refcnt, 1);
12030         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12031         calls->o = (*env)->NewWeakGlobalRef(env, o);
12032         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12033         CHECK(calls->persist_new_channel_meth != NULL);
12034         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12035         CHECK(calls->update_persisted_channel_meth != NULL);
12036
12037         LDKPersist ret = {
12038                 .this_arg = (void*) calls,
12039                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
12040                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
12041                 .free = LDKPersist_JCalls_free,
12042         };
12043         return ret;
12044 }
12045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
12046         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
12047         *res_ptr = LDKPersist_init(env, clz, o);
12048         return tag_ptr(res_ptr, true);
12049 }
12050 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) {
12051         void* this_arg_ptr = untag_ptr(this_arg);
12052         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12053         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12054         LDKOutPoint channel_id_conv;
12055         channel_id_conv.inner = untag_ptr(channel_id);
12056         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12057         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12058         channel_id_conv = OutPoint_clone(&channel_id_conv);
12059         LDKChannelMonitor data_conv;
12060         data_conv.inner = untag_ptr(data);
12061         data_conv.is_owned = ptr_is_owned(data);
12062         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12063         data_conv.is_owned = false;
12064         LDKMonitorUpdateId update_id_conv;
12065         update_id_conv.inner = untag_ptr(update_id);
12066         update_id_conv.is_owned = ptr_is_owned(update_id);
12067         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12068         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12069         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));
12070         return ret_conv;
12071 }
12072
12073 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) {
12074         void* this_arg_ptr = untag_ptr(this_arg);
12075         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12076         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12077         LDKOutPoint channel_id_conv;
12078         channel_id_conv.inner = untag_ptr(channel_id);
12079         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12080         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12081         channel_id_conv = OutPoint_clone(&channel_id_conv);
12082         LDKChannelMonitorUpdate update_conv;
12083         update_conv.inner = untag_ptr(update);
12084         update_conv.is_owned = ptr_is_owned(update);
12085         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
12086         update_conv.is_owned = false;
12087         LDKChannelMonitor data_conv;
12088         data_conv.inner = untag_ptr(data);
12089         data_conv.is_owned = ptr_is_owned(data);
12090         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12091         data_conv.is_owned = false;
12092         LDKMonitorUpdateId update_id_conv;
12093         update_id_conv.inner = untag_ptr(update_id);
12094         update_id_conv.is_owned = ptr_is_owned(update_id);
12095         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12096         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12097         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));
12098         return ret_conv;
12099 }
12100
12101 typedef struct LDKChannelMessageHandler_JCalls {
12102         atomic_size_t refcnt;
12103         JavaVM *vm;
12104         jweak o;
12105         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12106         jmethodID handle_open_channel_meth;
12107         jmethodID handle_accept_channel_meth;
12108         jmethodID handle_funding_created_meth;
12109         jmethodID handle_funding_signed_meth;
12110         jmethodID handle_channel_ready_meth;
12111         jmethodID handle_shutdown_meth;
12112         jmethodID handle_closing_signed_meth;
12113         jmethodID handle_update_add_htlc_meth;
12114         jmethodID handle_update_fulfill_htlc_meth;
12115         jmethodID handle_update_fail_htlc_meth;
12116         jmethodID handle_update_fail_malformed_htlc_meth;
12117         jmethodID handle_commitment_signed_meth;
12118         jmethodID handle_revoke_and_ack_meth;
12119         jmethodID handle_update_fee_meth;
12120         jmethodID handle_announcement_signatures_meth;
12121         jmethodID peer_disconnected_meth;
12122         jmethodID peer_connected_meth;
12123         jmethodID handle_channel_reestablish_meth;
12124         jmethodID handle_channel_update_meth;
12125         jmethodID handle_error_meth;
12126         jmethodID provided_node_features_meth;
12127         jmethodID provided_init_features_meth;
12128 } LDKChannelMessageHandler_JCalls;
12129 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
12130         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12131         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12132                 JNIEnv *env;
12133                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12134                 if (get_jenv_res == JNI_EDETACHED) {
12135                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12136                 } else {
12137                         DO_ASSERT(get_jenv_res == JNI_OK);
12138                 }
12139                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12140                 if (get_jenv_res == JNI_EDETACHED) {
12141                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12142                 }
12143                 FREE(j_calls);
12144         }
12145 }
12146 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
12147         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12148         JNIEnv *env;
12149         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12150         if (get_jenv_res == JNI_EDETACHED) {
12151                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12152         } else {
12153                 DO_ASSERT(get_jenv_res == JNI_OK);
12154         }
12155         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12156         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12157         LDKInitFeatures their_features_var = their_features;
12158         int64_t their_features_ref = 0;
12159         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12160         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12161         LDKOpenChannel msg_var = *msg;
12162         int64_t msg_ref = 0;
12163         msg_var = OpenChannel_clone(&msg_var);
12164         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12165         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12166         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12167         CHECK(obj != NULL);
12168         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
12169         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12170                 (*env)->ExceptionDescribe(env);
12171                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
12172         }
12173         if (get_jenv_res == JNI_EDETACHED) {
12174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12175         }
12176 }
12177 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
12178         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12179         JNIEnv *env;
12180         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12181         if (get_jenv_res == JNI_EDETACHED) {
12182                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12183         } else {
12184                 DO_ASSERT(get_jenv_res == JNI_OK);
12185         }
12186         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12187         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12188         LDKInitFeatures their_features_var = their_features;
12189         int64_t their_features_ref = 0;
12190         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12191         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12192         LDKAcceptChannel msg_var = *msg;
12193         int64_t msg_ref = 0;
12194         msg_var = AcceptChannel_clone(&msg_var);
12195         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12196         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12197         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12198         CHECK(obj != NULL);
12199         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
12200         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12201                 (*env)->ExceptionDescribe(env);
12202                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
12203         }
12204         if (get_jenv_res == JNI_EDETACHED) {
12205                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12206         }
12207 }
12208 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
12209         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12210         JNIEnv *env;
12211         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12212         if (get_jenv_res == JNI_EDETACHED) {
12213                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12214         } else {
12215                 DO_ASSERT(get_jenv_res == JNI_OK);
12216         }
12217         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12218         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12219         LDKFundingCreated msg_var = *msg;
12220         int64_t msg_ref = 0;
12221         msg_var = FundingCreated_clone(&msg_var);
12222         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12223         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12224         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12225         CHECK(obj != NULL);
12226         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
12227         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12228                 (*env)->ExceptionDescribe(env);
12229                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
12230         }
12231         if (get_jenv_res == JNI_EDETACHED) {
12232                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12233         }
12234 }
12235 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
12236         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12237         JNIEnv *env;
12238         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12239         if (get_jenv_res == JNI_EDETACHED) {
12240                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12241         } else {
12242                 DO_ASSERT(get_jenv_res == JNI_OK);
12243         }
12244         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12245         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12246         LDKFundingSigned msg_var = *msg;
12247         int64_t msg_ref = 0;
12248         msg_var = FundingSigned_clone(&msg_var);
12249         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12250         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12251         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12252         CHECK(obj != NULL);
12253         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
12254         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12255                 (*env)->ExceptionDescribe(env);
12256                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
12257         }
12258         if (get_jenv_res == JNI_EDETACHED) {
12259                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12260         }
12261 }
12262 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
12263         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12264         JNIEnv *env;
12265         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12266         if (get_jenv_res == JNI_EDETACHED) {
12267                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12268         } else {
12269                 DO_ASSERT(get_jenv_res == JNI_OK);
12270         }
12271         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12272         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12273         LDKChannelReady msg_var = *msg;
12274         int64_t msg_ref = 0;
12275         msg_var = ChannelReady_clone(&msg_var);
12276         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12277         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12278         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12279         CHECK(obj != NULL);
12280         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
12281         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12282                 (*env)->ExceptionDescribe(env);
12283                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
12284         }
12285         if (get_jenv_res == JNI_EDETACHED) {
12286                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12287         }
12288 }
12289 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
12290         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12291         JNIEnv *env;
12292         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12293         if (get_jenv_res == JNI_EDETACHED) {
12294                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12295         } else {
12296                 DO_ASSERT(get_jenv_res == JNI_OK);
12297         }
12298         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12299         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12300         LDKInitFeatures their_features_var = *their_features;
12301         int64_t their_features_ref = 0;
12302         their_features_var = InitFeatures_clone(&their_features_var);
12303         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12304         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12305         LDKShutdown msg_var = *msg;
12306         int64_t msg_ref = 0;
12307         msg_var = Shutdown_clone(&msg_var);
12308         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12309         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12310         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12311         CHECK(obj != NULL);
12312         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
12313         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12314                 (*env)->ExceptionDescribe(env);
12315                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
12316         }
12317         if (get_jenv_res == JNI_EDETACHED) {
12318                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12319         }
12320 }
12321 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12322         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12323         JNIEnv *env;
12324         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12325         if (get_jenv_res == JNI_EDETACHED) {
12326                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12327         } else {
12328                 DO_ASSERT(get_jenv_res == JNI_OK);
12329         }
12330         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12331         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12332         LDKClosingSigned msg_var = *msg;
12333         int64_t msg_ref = 0;
12334         msg_var = ClosingSigned_clone(&msg_var);
12335         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12336         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12337         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12338         CHECK(obj != NULL);
12339         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
12340         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12341                 (*env)->ExceptionDescribe(env);
12342                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
12343         }
12344         if (get_jenv_res == JNI_EDETACHED) {
12345                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12346         }
12347 }
12348 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
12349         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12350         JNIEnv *env;
12351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12352         if (get_jenv_res == JNI_EDETACHED) {
12353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12354         } else {
12355                 DO_ASSERT(get_jenv_res == JNI_OK);
12356         }
12357         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12358         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12359         LDKUpdateAddHTLC msg_var = *msg;
12360         int64_t msg_ref = 0;
12361         msg_var = UpdateAddHTLC_clone(&msg_var);
12362         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12363         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12365         CHECK(obj != NULL);
12366         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
12367         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12368                 (*env)->ExceptionDescribe(env);
12369                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
12370         }
12371         if (get_jenv_res == JNI_EDETACHED) {
12372                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12373         }
12374 }
12375 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
12376         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12377         JNIEnv *env;
12378         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12379         if (get_jenv_res == JNI_EDETACHED) {
12380                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12381         } else {
12382                 DO_ASSERT(get_jenv_res == JNI_OK);
12383         }
12384         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12385         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12386         LDKUpdateFulfillHTLC msg_var = *msg;
12387         int64_t msg_ref = 0;
12388         msg_var = UpdateFulfillHTLC_clone(&msg_var);
12389         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12390         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12391         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12392         CHECK(obj != NULL);
12393         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
12394         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12395                 (*env)->ExceptionDescribe(env);
12396                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
12397         }
12398         if (get_jenv_res == JNI_EDETACHED) {
12399                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12400         }
12401 }
12402 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
12403         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12404         JNIEnv *env;
12405         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12406         if (get_jenv_res == JNI_EDETACHED) {
12407                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12408         } else {
12409                 DO_ASSERT(get_jenv_res == JNI_OK);
12410         }
12411         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12412         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12413         LDKUpdateFailHTLC msg_var = *msg;
12414         int64_t msg_ref = 0;
12415         msg_var = UpdateFailHTLC_clone(&msg_var);
12416         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12417         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12418         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12419         CHECK(obj != NULL);
12420         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
12421         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12422                 (*env)->ExceptionDescribe(env);
12423                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
12424         }
12425         if (get_jenv_res == JNI_EDETACHED) {
12426                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12427         }
12428 }
12429 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12430         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12431         JNIEnv *env;
12432         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12433         if (get_jenv_res == JNI_EDETACHED) {
12434                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12435         } else {
12436                 DO_ASSERT(get_jenv_res == JNI_OK);
12437         }
12438         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12439         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12440         LDKUpdateFailMalformedHTLC msg_var = *msg;
12441         int64_t msg_ref = 0;
12442         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12443         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12444         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12445         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12446         CHECK(obj != NULL);
12447         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12448         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12449                 (*env)->ExceptionDescribe(env);
12450                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12451         }
12452         if (get_jenv_res == JNI_EDETACHED) {
12453                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12454         }
12455 }
12456 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12457         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12458         JNIEnv *env;
12459         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12460         if (get_jenv_res == JNI_EDETACHED) {
12461                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12462         } else {
12463                 DO_ASSERT(get_jenv_res == JNI_OK);
12464         }
12465         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12466         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12467         LDKCommitmentSigned msg_var = *msg;
12468         int64_t msg_ref = 0;
12469         msg_var = CommitmentSigned_clone(&msg_var);
12470         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12471         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12472         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12473         CHECK(obj != NULL);
12474         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12475         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12476                 (*env)->ExceptionDescribe(env);
12477                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12478         }
12479         if (get_jenv_res == JNI_EDETACHED) {
12480                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12481         }
12482 }
12483 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12484         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12485         JNIEnv *env;
12486         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12487         if (get_jenv_res == JNI_EDETACHED) {
12488                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12489         } else {
12490                 DO_ASSERT(get_jenv_res == JNI_OK);
12491         }
12492         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12493         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12494         LDKRevokeAndACK msg_var = *msg;
12495         int64_t msg_ref = 0;
12496         msg_var = RevokeAndACK_clone(&msg_var);
12497         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12498         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12499         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12500         CHECK(obj != NULL);
12501         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12502         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12503                 (*env)->ExceptionDescribe(env);
12504                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12505         }
12506         if (get_jenv_res == JNI_EDETACHED) {
12507                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12508         }
12509 }
12510 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12511         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12512         JNIEnv *env;
12513         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12514         if (get_jenv_res == JNI_EDETACHED) {
12515                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12516         } else {
12517                 DO_ASSERT(get_jenv_res == JNI_OK);
12518         }
12519         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12520         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12521         LDKUpdateFee msg_var = *msg;
12522         int64_t msg_ref = 0;
12523         msg_var = UpdateFee_clone(&msg_var);
12524         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12525         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12526         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12527         CHECK(obj != NULL);
12528         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12529         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12530                 (*env)->ExceptionDescribe(env);
12531                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12532         }
12533         if (get_jenv_res == JNI_EDETACHED) {
12534                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12535         }
12536 }
12537 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12538         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12539         JNIEnv *env;
12540         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12541         if (get_jenv_res == JNI_EDETACHED) {
12542                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12543         } else {
12544                 DO_ASSERT(get_jenv_res == JNI_OK);
12545         }
12546         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12547         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12548         LDKAnnouncementSignatures msg_var = *msg;
12549         int64_t msg_ref = 0;
12550         msg_var = AnnouncementSignatures_clone(&msg_var);
12551         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12552         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12553         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12554         CHECK(obj != NULL);
12555         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12556         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12557                 (*env)->ExceptionDescribe(env);
12558                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12559         }
12560         if (get_jenv_res == JNI_EDETACHED) {
12561                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12562         }
12563 }
12564 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12565         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12566         JNIEnv *env;
12567         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12568         if (get_jenv_res == JNI_EDETACHED) {
12569                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12570         } else {
12571                 DO_ASSERT(get_jenv_res == JNI_OK);
12572         }
12573         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12574         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12575         jboolean no_connection_possible_conv = no_connection_possible;
12576         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12577         CHECK(obj != NULL);
12578         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12579         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12580                 (*env)->ExceptionDescribe(env);
12581                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12582         }
12583         if (get_jenv_res == JNI_EDETACHED) {
12584                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12585         }
12586 }
12587 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12588         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12589         JNIEnv *env;
12590         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12591         if (get_jenv_res == JNI_EDETACHED) {
12592                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12593         } else {
12594                 DO_ASSERT(get_jenv_res == JNI_OK);
12595         }
12596         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12597         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12598         LDKInit msg_var = *msg;
12599         int64_t msg_ref = 0;
12600         msg_var = Init_clone(&msg_var);
12601         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12602         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12603         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12604         CHECK(obj != NULL);
12605         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12606         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12607                 (*env)->ExceptionDescribe(env);
12608                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12609         }
12610         void* ret_ptr = untag_ptr(ret);
12611         CHECK_ACCESS(ret_ptr);
12612         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
12613         FREE(untag_ptr(ret));
12614         if (get_jenv_res == JNI_EDETACHED) {
12615                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12616         }
12617         return ret_conv;
12618 }
12619 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12620         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12621         JNIEnv *env;
12622         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12623         if (get_jenv_res == JNI_EDETACHED) {
12624                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12625         } else {
12626                 DO_ASSERT(get_jenv_res == JNI_OK);
12627         }
12628         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12629         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12630         LDKChannelReestablish msg_var = *msg;
12631         int64_t msg_ref = 0;
12632         msg_var = ChannelReestablish_clone(&msg_var);
12633         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12634         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12635         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12636         CHECK(obj != NULL);
12637         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12638         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12639                 (*env)->ExceptionDescribe(env);
12640                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12641         }
12642         if (get_jenv_res == JNI_EDETACHED) {
12643                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12644         }
12645 }
12646 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12647         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12648         JNIEnv *env;
12649         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12650         if (get_jenv_res == JNI_EDETACHED) {
12651                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12652         } else {
12653                 DO_ASSERT(get_jenv_res == JNI_OK);
12654         }
12655         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12656         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12657         LDKChannelUpdate msg_var = *msg;
12658         int64_t msg_ref = 0;
12659         msg_var = ChannelUpdate_clone(&msg_var);
12660         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12661         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12662         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12663         CHECK(obj != NULL);
12664         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12665         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12666                 (*env)->ExceptionDescribe(env);
12667                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12668         }
12669         if (get_jenv_res == JNI_EDETACHED) {
12670                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12671         }
12672 }
12673 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12674         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12675         JNIEnv *env;
12676         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12677         if (get_jenv_res == JNI_EDETACHED) {
12678                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12679         } else {
12680                 DO_ASSERT(get_jenv_res == JNI_OK);
12681         }
12682         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12683         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12684         LDKErrorMessage msg_var = *msg;
12685         int64_t msg_ref = 0;
12686         msg_var = ErrorMessage_clone(&msg_var);
12687         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12688         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12689         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12690         CHECK(obj != NULL);
12691         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12692         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12693                 (*env)->ExceptionDescribe(env);
12694                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12695         }
12696         if (get_jenv_res == JNI_EDETACHED) {
12697                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12698         }
12699 }
12700 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
12701         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12702         JNIEnv *env;
12703         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12704         if (get_jenv_res == JNI_EDETACHED) {
12705                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12706         } else {
12707                 DO_ASSERT(get_jenv_res == JNI_OK);
12708         }
12709         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12710         CHECK(obj != NULL);
12711         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
12712         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12713                 (*env)->ExceptionDescribe(env);
12714                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
12715         }
12716         LDKNodeFeatures ret_conv;
12717         ret_conv.inner = untag_ptr(ret);
12718         ret_conv.is_owned = ptr_is_owned(ret);
12719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12720         if (get_jenv_res == JNI_EDETACHED) {
12721                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12722         }
12723         return ret_conv;
12724 }
12725 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
12726         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12727         JNIEnv *env;
12728         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12729         if (get_jenv_res == JNI_EDETACHED) {
12730                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12731         } else {
12732                 DO_ASSERT(get_jenv_res == JNI_OK);
12733         }
12734         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12735         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12736         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12737         CHECK(obj != NULL);
12738         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
12739         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12740                 (*env)->ExceptionDescribe(env);
12741                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
12742         }
12743         LDKInitFeatures ret_conv;
12744         ret_conv.inner = untag_ptr(ret);
12745         ret_conv.is_owned = ptr_is_owned(ret);
12746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12747         if (get_jenv_res == JNI_EDETACHED) {
12748                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12749         }
12750         return ret_conv;
12751 }
12752 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12753         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12754         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12755         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12756 }
12757 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12758         jclass c = (*env)->GetObjectClass(env, o);
12759         CHECK(c != NULL);
12760         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12761         atomic_init(&calls->refcnt, 1);
12762         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12763         calls->o = (*env)->NewWeakGlobalRef(env, o);
12764         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12765         CHECK(calls->handle_open_channel_meth != NULL);
12766         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12767         CHECK(calls->handle_accept_channel_meth != NULL);
12768         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12769         CHECK(calls->handle_funding_created_meth != NULL);
12770         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12771         CHECK(calls->handle_funding_signed_meth != NULL);
12772         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12773         CHECK(calls->handle_channel_ready_meth != NULL);
12774         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12775         CHECK(calls->handle_shutdown_meth != NULL);
12776         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12777         CHECK(calls->handle_closing_signed_meth != NULL);
12778         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12779         CHECK(calls->handle_update_add_htlc_meth != NULL);
12780         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12781         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12782         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12783         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12784         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12785         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12786         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12787         CHECK(calls->handle_commitment_signed_meth != NULL);
12788         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12789         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12790         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12791         CHECK(calls->handle_update_fee_meth != NULL);
12792         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12793         CHECK(calls->handle_announcement_signatures_meth != NULL);
12794         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12795         CHECK(calls->peer_disconnected_meth != NULL);
12796         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
12797         CHECK(calls->peer_connected_meth != NULL);
12798         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12799         CHECK(calls->handle_channel_reestablish_meth != NULL);
12800         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12801         CHECK(calls->handle_channel_update_meth != NULL);
12802         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12803         CHECK(calls->handle_error_meth != NULL);
12804         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
12805         CHECK(calls->provided_node_features_meth != NULL);
12806         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
12807         CHECK(calls->provided_init_features_meth != NULL);
12808
12809         LDKChannelMessageHandler ret = {
12810                 .this_arg = (void*) calls,
12811                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12812                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12813                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12814                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12815                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12816                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12817                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12818                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12819                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12820                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12821                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12822                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12823                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12824                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12825                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12826                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12827                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12828                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12829                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12830                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12831                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
12832                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
12833                 .free = LDKChannelMessageHandler_JCalls_free,
12834                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12835         };
12836         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12837         return ret;
12838 }
12839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12840         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12841         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12842         return tag_ptr(res_ptr, true);
12843 }
12844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12845         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
12846         return tag_ptr(&inp->MessageSendEventsProvider, false);
12847 }
12848 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) {
12849         void* this_arg_ptr = untag_ptr(this_arg);
12850         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12851         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12852         LDKPublicKey their_node_id_ref;
12853         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12854         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12855         LDKInitFeatures their_features_conv;
12856         their_features_conv.inner = untag_ptr(their_features);
12857         their_features_conv.is_owned = ptr_is_owned(their_features);
12858         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12859         their_features_conv = InitFeatures_clone(&their_features_conv);
12860         LDKOpenChannel msg_conv;
12861         msg_conv.inner = untag_ptr(msg);
12862         msg_conv.is_owned = ptr_is_owned(msg);
12863         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12864         msg_conv.is_owned = false;
12865         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12866 }
12867
12868 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) {
12869         void* this_arg_ptr = untag_ptr(this_arg);
12870         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12871         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12872         LDKPublicKey their_node_id_ref;
12873         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12874         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12875         LDKInitFeatures their_features_conv;
12876         their_features_conv.inner = untag_ptr(their_features);
12877         their_features_conv.is_owned = ptr_is_owned(their_features);
12878         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12879         their_features_conv = InitFeatures_clone(&their_features_conv);
12880         LDKAcceptChannel msg_conv;
12881         msg_conv.inner = untag_ptr(msg);
12882         msg_conv.is_owned = ptr_is_owned(msg);
12883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12884         msg_conv.is_owned = false;
12885         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12886 }
12887
12888 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) {
12889         void* this_arg_ptr = untag_ptr(this_arg);
12890         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12891         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12892         LDKPublicKey their_node_id_ref;
12893         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12894         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12895         LDKFundingCreated msg_conv;
12896         msg_conv.inner = untag_ptr(msg);
12897         msg_conv.is_owned = ptr_is_owned(msg);
12898         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12899         msg_conv.is_owned = false;
12900         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12901 }
12902
12903 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) {
12904         void* this_arg_ptr = untag_ptr(this_arg);
12905         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12906         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12907         LDKPublicKey their_node_id_ref;
12908         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12909         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12910         LDKFundingSigned msg_conv;
12911         msg_conv.inner = untag_ptr(msg);
12912         msg_conv.is_owned = ptr_is_owned(msg);
12913         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12914         msg_conv.is_owned = false;
12915         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12916 }
12917
12918 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) {
12919         void* this_arg_ptr = untag_ptr(this_arg);
12920         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12921         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12922         LDKPublicKey their_node_id_ref;
12923         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12924         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12925         LDKChannelReady msg_conv;
12926         msg_conv.inner = untag_ptr(msg);
12927         msg_conv.is_owned = ptr_is_owned(msg);
12928         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12929         msg_conv.is_owned = false;
12930         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12931 }
12932
12933 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) {
12934         void* this_arg_ptr = untag_ptr(this_arg);
12935         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12936         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12937         LDKPublicKey their_node_id_ref;
12938         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12939         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12940         LDKInitFeatures their_features_conv;
12941         their_features_conv.inner = untag_ptr(their_features);
12942         their_features_conv.is_owned = ptr_is_owned(their_features);
12943         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12944         their_features_conv.is_owned = false;
12945         LDKShutdown msg_conv;
12946         msg_conv.inner = untag_ptr(msg);
12947         msg_conv.is_owned = ptr_is_owned(msg);
12948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12949         msg_conv.is_owned = false;
12950         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12951 }
12952
12953 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) {
12954         void* this_arg_ptr = untag_ptr(this_arg);
12955         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12956         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12957         LDKPublicKey their_node_id_ref;
12958         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12959         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12960         LDKClosingSigned msg_conv;
12961         msg_conv.inner = untag_ptr(msg);
12962         msg_conv.is_owned = ptr_is_owned(msg);
12963         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12964         msg_conv.is_owned = false;
12965         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12966 }
12967
12968 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) {
12969         void* this_arg_ptr = untag_ptr(this_arg);
12970         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12971         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12972         LDKPublicKey their_node_id_ref;
12973         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12974         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12975         LDKUpdateAddHTLC msg_conv;
12976         msg_conv.inner = untag_ptr(msg);
12977         msg_conv.is_owned = ptr_is_owned(msg);
12978         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12979         msg_conv.is_owned = false;
12980         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12981 }
12982
12983 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) {
12984         void* this_arg_ptr = untag_ptr(this_arg);
12985         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12986         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12987         LDKPublicKey their_node_id_ref;
12988         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12989         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12990         LDKUpdateFulfillHTLC msg_conv;
12991         msg_conv.inner = untag_ptr(msg);
12992         msg_conv.is_owned = ptr_is_owned(msg);
12993         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12994         msg_conv.is_owned = false;
12995         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12996 }
12997
12998 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) {
12999         void* this_arg_ptr = untag_ptr(this_arg);
13000         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13001         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13002         LDKPublicKey their_node_id_ref;
13003         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13004         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13005         LDKUpdateFailHTLC msg_conv;
13006         msg_conv.inner = untag_ptr(msg);
13007         msg_conv.is_owned = ptr_is_owned(msg);
13008         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13009         msg_conv.is_owned = false;
13010         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13011 }
13012
13013 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) {
13014         void* this_arg_ptr = untag_ptr(this_arg);
13015         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13016         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13017         LDKPublicKey their_node_id_ref;
13018         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13019         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13020         LDKUpdateFailMalformedHTLC msg_conv;
13021         msg_conv.inner = untag_ptr(msg);
13022         msg_conv.is_owned = ptr_is_owned(msg);
13023         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13024         msg_conv.is_owned = false;
13025         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13026 }
13027
13028 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) {
13029         void* this_arg_ptr = untag_ptr(this_arg);
13030         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13031         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13032         LDKPublicKey their_node_id_ref;
13033         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13034         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13035         LDKCommitmentSigned msg_conv;
13036         msg_conv.inner = untag_ptr(msg);
13037         msg_conv.is_owned = ptr_is_owned(msg);
13038         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13039         msg_conv.is_owned = false;
13040         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13041 }
13042
13043 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) {
13044         void* this_arg_ptr = untag_ptr(this_arg);
13045         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13046         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13047         LDKPublicKey their_node_id_ref;
13048         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13049         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13050         LDKRevokeAndACK msg_conv;
13051         msg_conv.inner = untag_ptr(msg);
13052         msg_conv.is_owned = ptr_is_owned(msg);
13053         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13054         msg_conv.is_owned = false;
13055         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13056 }
13057
13058 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) {
13059         void* this_arg_ptr = untag_ptr(this_arg);
13060         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13061         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13062         LDKPublicKey their_node_id_ref;
13063         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13064         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13065         LDKUpdateFee msg_conv;
13066         msg_conv.inner = untag_ptr(msg);
13067         msg_conv.is_owned = ptr_is_owned(msg);
13068         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13069         msg_conv.is_owned = false;
13070         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13071 }
13072
13073 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) {
13074         void* this_arg_ptr = untag_ptr(this_arg);
13075         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13076         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13077         LDKPublicKey their_node_id_ref;
13078         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13079         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13080         LDKAnnouncementSignatures msg_conv;
13081         msg_conv.inner = untag_ptr(msg);
13082         msg_conv.is_owned = ptr_is_owned(msg);
13083         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13084         msg_conv.is_owned = false;
13085         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13086 }
13087
13088 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) {
13089         void* this_arg_ptr = untag_ptr(this_arg);
13090         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13091         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13092         LDKPublicKey their_node_id_ref;
13093         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13094         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13095         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
13096 }
13097
13098 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) {
13099         void* this_arg_ptr = untag_ptr(this_arg);
13100         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13101         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13102         LDKPublicKey their_node_id_ref;
13103         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13104         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13105         LDKInit msg_conv;
13106         msg_conv.inner = untag_ptr(msg);
13107         msg_conv.is_owned = ptr_is_owned(msg);
13108         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13109         msg_conv.is_owned = false;
13110         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13111         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13112         return tag_ptr(ret_conv, true);
13113 }
13114
13115 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) {
13116         void* this_arg_ptr = untag_ptr(this_arg);
13117         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13118         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13119         LDKPublicKey their_node_id_ref;
13120         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13121         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13122         LDKChannelReestablish msg_conv;
13123         msg_conv.inner = untag_ptr(msg);
13124         msg_conv.is_owned = ptr_is_owned(msg);
13125         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13126         msg_conv.is_owned = false;
13127         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13128 }
13129
13130 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) {
13131         void* this_arg_ptr = untag_ptr(this_arg);
13132         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13133         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13134         LDKPublicKey their_node_id_ref;
13135         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13136         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13137         LDKChannelUpdate msg_conv;
13138         msg_conv.inner = untag_ptr(msg);
13139         msg_conv.is_owned = ptr_is_owned(msg);
13140         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13141         msg_conv.is_owned = false;
13142         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13143 }
13144
13145 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) {
13146         void* this_arg_ptr = untag_ptr(this_arg);
13147         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13148         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13149         LDKPublicKey their_node_id_ref;
13150         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13151         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13152         LDKErrorMessage msg_conv;
13153         msg_conv.inner = untag_ptr(msg);
13154         msg_conv.is_owned = ptr_is_owned(msg);
13155         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13156         msg_conv.is_owned = false;
13157         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13158 }
13159
13160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13161         void* this_arg_ptr = untag_ptr(this_arg);
13162         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13163         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13164         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13165         int64_t ret_ref = 0;
13166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13167         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13168         return ret_ref;
13169 }
13170
13171 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) {
13172         void* this_arg_ptr = untag_ptr(this_arg);
13173         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13174         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13175         LDKPublicKey their_node_id_ref;
13176         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13177         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13178         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13179         int64_t ret_ref = 0;
13180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13182         return ret_ref;
13183 }
13184
13185 typedef struct LDKRoutingMessageHandler_JCalls {
13186         atomic_size_t refcnt;
13187         JavaVM *vm;
13188         jweak o;
13189         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
13190         jmethodID handle_node_announcement_meth;
13191         jmethodID handle_channel_announcement_meth;
13192         jmethodID handle_channel_update_meth;
13193         jmethodID get_next_channel_announcement_meth;
13194         jmethodID get_next_node_announcement_meth;
13195         jmethodID peer_connected_meth;
13196         jmethodID handle_reply_channel_range_meth;
13197         jmethodID handle_reply_short_channel_ids_end_meth;
13198         jmethodID handle_query_channel_range_meth;
13199         jmethodID handle_query_short_channel_ids_meth;
13200         jmethodID provided_node_features_meth;
13201         jmethodID provided_init_features_meth;
13202 } LDKRoutingMessageHandler_JCalls;
13203 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
13204         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13205         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13206                 JNIEnv *env;
13207                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13208                 if (get_jenv_res == JNI_EDETACHED) {
13209                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13210                 } else {
13211                         DO_ASSERT(get_jenv_res == JNI_OK);
13212                 }
13213                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13214                 if (get_jenv_res == JNI_EDETACHED) {
13215                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13216                 }
13217                 FREE(j_calls);
13218         }
13219 }
13220 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
13221         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13222         JNIEnv *env;
13223         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13224         if (get_jenv_res == JNI_EDETACHED) {
13225                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13226         } else {
13227                 DO_ASSERT(get_jenv_res == JNI_OK);
13228         }
13229         LDKNodeAnnouncement msg_var = *msg;
13230         int64_t msg_ref = 0;
13231         msg_var = NodeAnnouncement_clone(&msg_var);
13232         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13233         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13234         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13235         CHECK(obj != NULL);
13236         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
13237         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13238                 (*env)->ExceptionDescribe(env);
13239                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13240         }
13241         void* ret_ptr = untag_ptr(ret);
13242         CHECK_ACCESS(ret_ptr);
13243         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13244         FREE(untag_ptr(ret));
13245         if (get_jenv_res == JNI_EDETACHED) {
13246                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13247         }
13248         return ret_conv;
13249 }
13250 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
13251         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13252         JNIEnv *env;
13253         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13254         if (get_jenv_res == JNI_EDETACHED) {
13255                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13256         } else {
13257                 DO_ASSERT(get_jenv_res == JNI_OK);
13258         }
13259         LDKChannelAnnouncement msg_var = *msg;
13260         int64_t msg_ref = 0;
13261         msg_var = ChannelAnnouncement_clone(&msg_var);
13262         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13263         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13264         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13265         CHECK(obj != NULL);
13266         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
13267         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13268                 (*env)->ExceptionDescribe(env);
13269                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13270         }
13271         void* ret_ptr = untag_ptr(ret);
13272         CHECK_ACCESS(ret_ptr);
13273         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13274         FREE(untag_ptr(ret));
13275         if (get_jenv_res == JNI_EDETACHED) {
13276                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13277         }
13278         return ret_conv;
13279 }
13280 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13281         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13282         JNIEnv *env;
13283         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13284         if (get_jenv_res == JNI_EDETACHED) {
13285                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13286         } else {
13287                 DO_ASSERT(get_jenv_res == JNI_OK);
13288         }
13289         LDKChannelUpdate msg_var = *msg;
13290         int64_t msg_ref = 0;
13291         msg_var = ChannelUpdate_clone(&msg_var);
13292         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13293         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13295         CHECK(obj != NULL);
13296         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
13297         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13298                 (*env)->ExceptionDescribe(env);
13299                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
13300         }
13301         void* ret_ptr = untag_ptr(ret);
13302         CHECK_ACCESS(ret_ptr);
13303         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13304         FREE(untag_ptr(ret));
13305         if (get_jenv_res == JNI_EDETACHED) {
13306                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13307         }
13308         return ret_conv;
13309 }
13310 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
13311         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13312         JNIEnv *env;
13313         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13314         if (get_jenv_res == JNI_EDETACHED) {
13315                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13316         } else {
13317                 DO_ASSERT(get_jenv_res == JNI_OK);
13318         }
13319         int64_t starting_point_conv = starting_point;
13320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13321         CHECK(obj != NULL);
13322         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
13323         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13324                 (*env)->ExceptionDescribe(env);
13325                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13326         }
13327         void* ret_ptr = untag_ptr(ret);
13328         CHECK_ACCESS(ret_ptr);
13329         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
13330         FREE(untag_ptr(ret));
13331         if (get_jenv_res == JNI_EDETACHED) {
13332                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13333         }
13334         return ret_conv;
13335 }
13336 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point) {
13337         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13338         JNIEnv *env;
13339         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13340         if (get_jenv_res == JNI_EDETACHED) {
13341                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13342         } else {
13343                 DO_ASSERT(get_jenv_res == JNI_OK);
13344         }
13345         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
13346         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
13347         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13348         CHECK(obj != NULL);
13349         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_arr);
13350         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13351                 (*env)->ExceptionDescribe(env);
13352                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13353         }
13354         LDKNodeAnnouncement ret_conv;
13355         ret_conv.inner = untag_ptr(ret);
13356         ret_conv.is_owned = ptr_is_owned(ret);
13357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13358         if (get_jenv_res == JNI_EDETACHED) {
13359                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13360         }
13361         return ret_conv;
13362 }
13363 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13364         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13365         JNIEnv *env;
13366         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13367         if (get_jenv_res == JNI_EDETACHED) {
13368                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13369         } else {
13370                 DO_ASSERT(get_jenv_res == JNI_OK);
13371         }
13372         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13373         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13374         LDKInit init_var = *init;
13375         int64_t init_ref = 0;
13376         init_var = Init_clone(&init_var);
13377         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13378         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13379         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13380         CHECK(obj != NULL);
13381         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13382         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13383                 (*env)->ExceptionDescribe(env);
13384                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
13385         }
13386         void* ret_ptr = untag_ptr(ret);
13387         CHECK_ACCESS(ret_ptr);
13388         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13389         FREE(untag_ptr(ret));
13390         if (get_jenv_res == JNI_EDETACHED) {
13391                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13392         }
13393         return ret_conv;
13394 }
13395 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13396         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13397         JNIEnv *env;
13398         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13399         if (get_jenv_res == JNI_EDETACHED) {
13400                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13401         } else {
13402                 DO_ASSERT(get_jenv_res == JNI_OK);
13403         }
13404         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13405         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13406         LDKReplyChannelRange msg_var = msg;
13407         int64_t msg_ref = 0;
13408         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13409         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13410         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13411         CHECK(obj != NULL);
13412         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
13413         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13414                 (*env)->ExceptionDescribe(env);
13415                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13416         }
13417         void* ret_ptr = untag_ptr(ret);
13418         CHECK_ACCESS(ret_ptr);
13419         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13420         FREE(untag_ptr(ret));
13421         if (get_jenv_res == JNI_EDETACHED) {
13422                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13423         }
13424         return ret_conv;
13425 }
13426 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
13427         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13428         JNIEnv *env;
13429         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13430         if (get_jenv_res == JNI_EDETACHED) {
13431                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13432         } else {
13433                 DO_ASSERT(get_jenv_res == JNI_OK);
13434         }
13435         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13436         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13437         LDKReplyShortChannelIdsEnd msg_var = msg;
13438         int64_t msg_ref = 0;
13439         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13440         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13441         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13442         CHECK(obj != NULL);
13443         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13444         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13445                 (*env)->ExceptionDescribe(env);
13446                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13447         }
13448         void* ret_ptr = untag_ptr(ret);
13449         CHECK_ACCESS(ret_ptr);
13450         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13451         FREE(untag_ptr(ret));
13452         if (get_jenv_res == JNI_EDETACHED) {
13453                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13454         }
13455         return ret_conv;
13456 }
13457 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13458         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13459         JNIEnv *env;
13460         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13461         if (get_jenv_res == JNI_EDETACHED) {
13462                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13463         } else {
13464                 DO_ASSERT(get_jenv_res == JNI_OK);
13465         }
13466         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13467         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13468         LDKQueryChannelRange msg_var = msg;
13469         int64_t msg_ref = 0;
13470         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13471         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13472         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13473         CHECK(obj != NULL);
13474         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13475         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13476                 (*env)->ExceptionDescribe(env);
13477                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13478         }
13479         void* ret_ptr = untag_ptr(ret);
13480         CHECK_ACCESS(ret_ptr);
13481         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13482         FREE(untag_ptr(ret));
13483         if (get_jenv_res == JNI_EDETACHED) {
13484                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13485         }
13486         return ret_conv;
13487 }
13488 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13489         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13490         JNIEnv *env;
13491         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13492         if (get_jenv_res == JNI_EDETACHED) {
13493                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13494         } else {
13495                 DO_ASSERT(get_jenv_res == JNI_OK);
13496         }
13497         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13498         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13499         LDKQueryShortChannelIds msg_var = msg;
13500         int64_t msg_ref = 0;
13501         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13502         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13503         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13504         CHECK(obj != NULL);
13505         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13506         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13507                 (*env)->ExceptionDescribe(env);
13508                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13509         }
13510         void* ret_ptr = untag_ptr(ret);
13511         CHECK_ACCESS(ret_ptr);
13512         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13513         FREE(untag_ptr(ret));
13514         if (get_jenv_res == JNI_EDETACHED) {
13515                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13516         }
13517         return ret_conv;
13518 }
13519 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
13520         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13521         JNIEnv *env;
13522         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13523         if (get_jenv_res == JNI_EDETACHED) {
13524                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13525         } else {
13526                 DO_ASSERT(get_jenv_res == JNI_OK);
13527         }
13528         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13529         CHECK(obj != NULL);
13530         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13531         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13532                 (*env)->ExceptionDescribe(env);
13533                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
13534         }
13535         LDKNodeFeatures ret_conv;
13536         ret_conv.inner = untag_ptr(ret);
13537         ret_conv.is_owned = ptr_is_owned(ret);
13538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13539         if (get_jenv_res == JNI_EDETACHED) {
13540                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13541         }
13542         return ret_conv;
13543 }
13544 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13545         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13546         JNIEnv *env;
13547         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13548         if (get_jenv_res == JNI_EDETACHED) {
13549                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13550         } else {
13551                 DO_ASSERT(get_jenv_res == JNI_OK);
13552         }
13553         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13554         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13555         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13556         CHECK(obj != NULL);
13557         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13558         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13559                 (*env)->ExceptionDescribe(env);
13560                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
13561         }
13562         LDKInitFeatures ret_conv;
13563         ret_conv.inner = untag_ptr(ret);
13564         ret_conv.is_owned = ptr_is_owned(ret);
13565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13566         if (get_jenv_res == JNI_EDETACHED) {
13567                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13568         }
13569         return ret_conv;
13570 }
13571 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13572         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13573         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13574         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13575 }
13576 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13577         jclass c = (*env)->GetObjectClass(env, o);
13578         CHECK(c != NULL);
13579         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13580         atomic_init(&calls->refcnt, 1);
13581         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13582         calls->o = (*env)->NewWeakGlobalRef(env, o);
13583         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13584         CHECK(calls->handle_node_announcement_meth != NULL);
13585         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13586         CHECK(calls->handle_channel_announcement_meth != NULL);
13587         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13588         CHECK(calls->handle_channel_update_meth != NULL);
13589         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
13590         CHECK(calls->get_next_channel_announcement_meth != NULL);
13591         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "([B)J");
13592         CHECK(calls->get_next_node_announcement_meth != NULL);
13593         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13594         CHECK(calls->peer_connected_meth != NULL);
13595         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13596         CHECK(calls->handle_reply_channel_range_meth != NULL);
13597         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13598         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13599         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13600         CHECK(calls->handle_query_channel_range_meth != NULL);
13601         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13602         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13603         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13604         CHECK(calls->provided_node_features_meth != NULL);
13605         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13606         CHECK(calls->provided_init_features_meth != NULL);
13607
13608         LDKRoutingMessageHandler ret = {
13609                 .this_arg = (void*) calls,
13610                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13611                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13612                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13613                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
13614                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
13615                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13616                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13617                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13618                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13619                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13620                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
13621                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
13622                 .free = LDKRoutingMessageHandler_JCalls_free,
13623                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13624         };
13625         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13626         return ret;
13627 }
13628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13629         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13630         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13631         return tag_ptr(res_ptr, true);
13632 }
13633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13634         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
13635         return tag_ptr(&inp->MessageSendEventsProvider, false);
13636 }
13637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13638         void* this_arg_ptr = untag_ptr(this_arg);
13639         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13640         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13641         LDKNodeAnnouncement msg_conv;
13642         msg_conv.inner = untag_ptr(msg);
13643         msg_conv.is_owned = ptr_is_owned(msg);
13644         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13645         msg_conv.is_owned = false;
13646         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13647         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13648         return tag_ptr(ret_conv, true);
13649 }
13650
13651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13652         void* this_arg_ptr = untag_ptr(this_arg);
13653         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13654         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13655         LDKChannelAnnouncement msg_conv;
13656         msg_conv.inner = untag_ptr(msg);
13657         msg_conv.is_owned = ptr_is_owned(msg);
13658         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13659         msg_conv.is_owned = false;
13660         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13661         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13662         return tag_ptr(ret_conv, true);
13663 }
13664
13665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13666         void* this_arg_ptr = untag_ptr(this_arg);
13667         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13668         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13669         LDKChannelUpdate msg_conv;
13670         msg_conv.inner = untag_ptr(msg);
13671         msg_conv.is_owned = ptr_is_owned(msg);
13672         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13673         msg_conv.is_owned = false;
13674         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13675         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13676         return tag_ptr(ret_conv, true);
13677 }
13678
13679 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) {
13680         void* this_arg_ptr = untag_ptr(this_arg);
13681         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13682         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13683         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
13684         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
13685         int64_t ret_ref = tag_ptr(ret_copy, true);
13686         return ret_ref;
13687 }
13688
13689 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) {
13690         void* this_arg_ptr = untag_ptr(this_arg);
13691         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13692         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13693         LDKPublicKey starting_point_ref;
13694         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13695         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13696         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_ref);
13697         int64_t ret_ref = 0;
13698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13700         return ret_ref;
13701 }
13702
13703 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) {
13704         void* this_arg_ptr = untag_ptr(this_arg);
13705         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13706         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13707         LDKPublicKey their_node_id_ref;
13708         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13709         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13710         LDKInit init_conv;
13711         init_conv.inner = untag_ptr(init);
13712         init_conv.is_owned = ptr_is_owned(init);
13713         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13714         init_conv.is_owned = false;
13715         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13716         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13717         return tag_ptr(ret_conv, true);
13718 }
13719
13720 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) {
13721         void* this_arg_ptr = untag_ptr(this_arg);
13722         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13723         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13724         LDKPublicKey their_node_id_ref;
13725         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13726         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13727         LDKReplyChannelRange msg_conv;
13728         msg_conv.inner = untag_ptr(msg);
13729         msg_conv.is_owned = ptr_is_owned(msg);
13730         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13731         msg_conv = ReplyChannelRange_clone(&msg_conv);
13732         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13733         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13734         return tag_ptr(ret_conv, true);
13735 }
13736
13737 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) {
13738         void* this_arg_ptr = untag_ptr(this_arg);
13739         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13740         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13741         LDKPublicKey their_node_id_ref;
13742         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13743         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13744         LDKReplyShortChannelIdsEnd msg_conv;
13745         msg_conv.inner = untag_ptr(msg);
13746         msg_conv.is_owned = ptr_is_owned(msg);
13747         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13748         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13749         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13750         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13751         return tag_ptr(ret_conv, true);
13752 }
13753
13754 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) {
13755         void* this_arg_ptr = untag_ptr(this_arg);
13756         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13757         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13758         LDKPublicKey their_node_id_ref;
13759         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13760         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13761         LDKQueryChannelRange msg_conv;
13762         msg_conv.inner = untag_ptr(msg);
13763         msg_conv.is_owned = ptr_is_owned(msg);
13764         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13765         msg_conv = QueryChannelRange_clone(&msg_conv);
13766         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13767         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13768         return tag_ptr(ret_conv, true);
13769 }
13770
13771 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) {
13772         void* this_arg_ptr = untag_ptr(this_arg);
13773         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13774         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13775         LDKPublicKey their_node_id_ref;
13776         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13777         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13778         LDKQueryShortChannelIds msg_conv;
13779         msg_conv.inner = untag_ptr(msg);
13780         msg_conv.is_owned = ptr_is_owned(msg);
13781         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13782         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13783         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13784         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13785         return tag_ptr(ret_conv, true);
13786 }
13787
13788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13789         void* this_arg_ptr = untag_ptr(this_arg);
13790         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13791         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13792         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13793         int64_t ret_ref = 0;
13794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13796         return ret_ref;
13797 }
13798
13799 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) {
13800         void* this_arg_ptr = untag_ptr(this_arg);
13801         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13802         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13803         LDKPublicKey their_node_id_ref;
13804         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13805         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13806         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13807         int64_t ret_ref = 0;
13808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13810         return ret_ref;
13811 }
13812
13813 typedef struct LDKOnionMessageHandler_JCalls {
13814         atomic_size_t refcnt;
13815         JavaVM *vm;
13816         jweak o;
13817         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
13818         jmethodID handle_onion_message_meth;
13819         jmethodID peer_connected_meth;
13820         jmethodID peer_disconnected_meth;
13821         jmethodID provided_node_features_meth;
13822         jmethodID provided_init_features_meth;
13823 } LDKOnionMessageHandler_JCalls;
13824 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
13825         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13826         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13827                 JNIEnv *env;
13828                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13829                 if (get_jenv_res == JNI_EDETACHED) {
13830                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13831                 } else {
13832                         DO_ASSERT(get_jenv_res == JNI_OK);
13833                 }
13834                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13835                 if (get_jenv_res == JNI_EDETACHED) {
13836                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13837                 }
13838                 FREE(j_calls);
13839         }
13840 }
13841 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
13842         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13843         JNIEnv *env;
13844         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13845         if (get_jenv_res == JNI_EDETACHED) {
13846                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13847         } else {
13848                 DO_ASSERT(get_jenv_res == JNI_OK);
13849         }
13850         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
13851         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
13852         LDKOnionMessage msg_var = *msg;
13853         int64_t msg_ref = 0;
13854         msg_var = OnionMessage_clone(&msg_var);
13855         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13856         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13857         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13858         CHECK(obj != NULL);
13859         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
13860         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13861                 (*env)->ExceptionDescribe(env);
13862                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
13863         }
13864         if (get_jenv_res == JNI_EDETACHED) {
13865                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13866         }
13867 }
13868 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13869         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13870         JNIEnv *env;
13871         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13872         if (get_jenv_res == JNI_EDETACHED) {
13873                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13874         } else {
13875                 DO_ASSERT(get_jenv_res == JNI_OK);
13876         }
13877         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13878         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13879         LDKInit init_var = *init;
13880         int64_t init_ref = 0;
13881         init_var = Init_clone(&init_var);
13882         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13883         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13885         CHECK(obj != NULL);
13886         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13887         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13888                 (*env)->ExceptionDescribe(env);
13889                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
13890         }
13891         void* ret_ptr = untag_ptr(ret);
13892         CHECK_ACCESS(ret_ptr);
13893         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13894         FREE(untag_ptr(ret));
13895         if (get_jenv_res == JNI_EDETACHED) {
13896                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13897         }
13898         return ret_conv;
13899 }
13900 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
13901         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13902         JNIEnv *env;
13903         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13904         if (get_jenv_res == JNI_EDETACHED) {
13905                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13906         } else {
13907                 DO_ASSERT(get_jenv_res == JNI_OK);
13908         }
13909         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13910         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13911         jboolean no_connection_possible_conv = no_connection_possible;
13912         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13913         CHECK(obj != NULL);
13914         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
13915         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13916                 (*env)->ExceptionDescribe(env);
13917                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
13918         }
13919         if (get_jenv_res == JNI_EDETACHED) {
13920                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13921         }
13922 }
13923 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
13924         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13925         JNIEnv *env;
13926         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13927         if (get_jenv_res == JNI_EDETACHED) {
13928                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13929         } else {
13930                 DO_ASSERT(get_jenv_res == JNI_OK);
13931         }
13932         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13933         CHECK(obj != NULL);
13934         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13935         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13936                 (*env)->ExceptionDescribe(env);
13937                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
13938         }
13939         LDKNodeFeatures ret_conv;
13940         ret_conv.inner = untag_ptr(ret);
13941         ret_conv.is_owned = ptr_is_owned(ret);
13942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13943         if (get_jenv_res == JNI_EDETACHED) {
13944                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13945         }
13946         return ret_conv;
13947 }
13948 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13949         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13950         JNIEnv *env;
13951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13952         if (get_jenv_res == JNI_EDETACHED) {
13953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13954         } else {
13955                 DO_ASSERT(get_jenv_res == JNI_OK);
13956         }
13957         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13958         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13959         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13960         CHECK(obj != NULL);
13961         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13962         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13963                 (*env)->ExceptionDescribe(env);
13964                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
13965         }
13966         LDKInitFeatures ret_conv;
13967         ret_conv.inner = untag_ptr(ret);
13968         ret_conv.is_owned = ptr_is_owned(ret);
13969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13970         if (get_jenv_res == JNI_EDETACHED) {
13971                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13972         }
13973         return ret_conv;
13974 }
13975 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
13976         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
13977         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13978         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
13979 }
13980 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13981         jclass c = (*env)->GetObjectClass(env, o);
13982         CHECK(c != NULL);
13983         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
13984         atomic_init(&calls->refcnt, 1);
13985         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13986         calls->o = (*env)->NewWeakGlobalRef(env, o);
13987         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
13988         CHECK(calls->handle_onion_message_meth != NULL);
13989         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13990         CHECK(calls->peer_connected_meth != NULL);
13991         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
13992         CHECK(calls->peer_disconnected_meth != NULL);
13993         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13994         CHECK(calls->provided_node_features_meth != NULL);
13995         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13996         CHECK(calls->provided_init_features_meth != NULL);
13997
13998         LDKOnionMessageHandler ret = {
13999                 .this_arg = (void*) calls,
14000                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
14001                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
14002                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
14003                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
14004                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
14005                 .free = LDKOnionMessageHandler_JCalls_free,
14006                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
14007         };
14008         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
14009         return ret;
14010 }
14011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
14012         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
14013         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
14014         return tag_ptr(res_ptr, true);
14015 }
14016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
14017         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
14018         return tag_ptr(&inp->OnionMessageProvider, false);
14019 }
14020 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) {
14021         void* this_arg_ptr = untag_ptr(this_arg);
14022         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14023         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14024         LDKPublicKey peer_node_id_ref;
14025         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
14026         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
14027         LDKOnionMessage msg_conv;
14028         msg_conv.inner = untag_ptr(msg);
14029         msg_conv.is_owned = ptr_is_owned(msg);
14030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14031         msg_conv.is_owned = false;
14032         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
14033 }
14034
14035 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) {
14036         void* this_arg_ptr = untag_ptr(this_arg);
14037         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14038         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14039         LDKPublicKey their_node_id_ref;
14040         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14041         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14042         LDKInit init_conv;
14043         init_conv.inner = untag_ptr(init);
14044         init_conv.is_owned = ptr_is_owned(init);
14045         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14046         init_conv.is_owned = false;
14047         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14048         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
14049         return tag_ptr(ret_conv, true);
14050 }
14051
14052 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) {
14053         void* this_arg_ptr = untag_ptr(this_arg);
14054         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14055         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14056         LDKPublicKey their_node_id_ref;
14057         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14058         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14059         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
14060 }
14061
14062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
14063         void* this_arg_ptr = untag_ptr(this_arg);
14064         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14065         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14066         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14067         int64_t ret_ref = 0;
14068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14070         return ret_ref;
14071 }
14072
14073 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) {
14074         void* this_arg_ptr = untag_ptr(this_arg);
14075         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14076         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14077         LDKPublicKey their_node_id_ref;
14078         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14079         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14080         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14081         int64_t ret_ref = 0;
14082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14084         return ret_ref;
14085 }
14086
14087 typedef struct LDKCustomMessageReader_JCalls {
14088         atomic_size_t refcnt;
14089         JavaVM *vm;
14090         jweak o;
14091         jmethodID read_meth;
14092 } LDKCustomMessageReader_JCalls;
14093 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
14094         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14095         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14096                 JNIEnv *env;
14097                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14098                 if (get_jenv_res == JNI_EDETACHED) {
14099                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14100                 } else {
14101                         DO_ASSERT(get_jenv_res == JNI_OK);
14102                 }
14103                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14104                 if (get_jenv_res == JNI_EDETACHED) {
14105                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14106                 }
14107                 FREE(j_calls);
14108         }
14109 }
14110 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
14111         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14112         JNIEnv *env;
14113         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14114         if (get_jenv_res == JNI_EDETACHED) {
14115                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14116         } else {
14117                 DO_ASSERT(get_jenv_res == JNI_OK);
14118         }
14119         int16_t message_type_conv = message_type;
14120         LDKu8slice buffer_var = buffer;
14121         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
14122         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
14123         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14124         CHECK(obj != NULL);
14125         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
14126         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14127                 (*env)->ExceptionDescribe(env);
14128                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
14129         }
14130         void* ret_ptr = untag_ptr(ret);
14131         CHECK_ACCESS(ret_ptr);
14132         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
14133         FREE(untag_ptr(ret));
14134         if (get_jenv_res == JNI_EDETACHED) {
14135                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14136         }
14137         return ret_conv;
14138 }
14139 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
14140         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
14141         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14142 }
14143 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
14144         jclass c = (*env)->GetObjectClass(env, o);
14145         CHECK(c != NULL);
14146         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
14147         atomic_init(&calls->refcnt, 1);
14148         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14149         calls->o = (*env)->NewWeakGlobalRef(env, o);
14150         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
14151         CHECK(calls->read_meth != NULL);
14152
14153         LDKCustomMessageReader ret = {
14154                 .this_arg = (void*) calls,
14155                 .read = read_LDKCustomMessageReader_jcall,
14156                 .free = LDKCustomMessageReader_JCalls_free,
14157         };
14158         return ret;
14159 }
14160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
14161         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
14162         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
14163         return tag_ptr(res_ptr, true);
14164 }
14165 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) {
14166         void* this_arg_ptr = untag_ptr(this_arg);
14167         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14168         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
14169         LDKu8slice buffer_ref;
14170         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
14171         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
14172         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14173         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
14174         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
14175         return tag_ptr(ret_conv, true);
14176 }
14177
14178 typedef struct LDKCustomMessageHandler_JCalls {
14179         atomic_size_t refcnt;
14180         JavaVM *vm;
14181         jweak o;
14182         LDKCustomMessageReader_JCalls* CustomMessageReader;
14183         jmethodID handle_custom_message_meth;
14184         jmethodID get_and_clear_pending_msg_meth;
14185 } LDKCustomMessageHandler_JCalls;
14186 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
14187         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14188         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14189                 JNIEnv *env;
14190                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14191                 if (get_jenv_res == JNI_EDETACHED) {
14192                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14193                 } else {
14194                         DO_ASSERT(get_jenv_res == JNI_OK);
14195                 }
14196                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14197                 if (get_jenv_res == JNI_EDETACHED) {
14198                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14199                 }
14200                 FREE(j_calls);
14201         }
14202 }
14203 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
14204         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14205         JNIEnv *env;
14206         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14207         if (get_jenv_res == JNI_EDETACHED) {
14208                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14209         } else {
14210                 DO_ASSERT(get_jenv_res == JNI_OK);
14211         }
14212         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
14213         *msg_ret = msg;
14214         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
14215         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
14216         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14217         CHECK(obj != NULL);
14218         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
14219         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14220                 (*env)->ExceptionDescribe(env);
14221                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
14222         }
14223         void* ret_ptr = untag_ptr(ret);
14224         CHECK_ACCESS(ret_ptr);
14225         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14226         FREE(untag_ptr(ret));
14227         if (get_jenv_res == JNI_EDETACHED) {
14228                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14229         }
14230         return ret_conv;
14231 }
14232 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
14233         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14234         JNIEnv *env;
14235         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14236         if (get_jenv_res == JNI_EDETACHED) {
14237                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14238         } else {
14239                 DO_ASSERT(get_jenv_res == JNI_OK);
14240         }
14241         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14242         CHECK(obj != NULL);
14243         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
14244         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14245                 (*env)->ExceptionDescribe(env);
14246                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
14247         }
14248         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
14249         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14250         if (ret_constr.datalen > 0)
14251                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
14252         else
14253                 ret_constr.data = NULL;
14254         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14255         for (size_t z = 0; z < ret_constr.datalen; z++) {
14256                 int64_t ret_conv_25 = ret_vals[z];
14257                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
14258                 CHECK_ACCESS(ret_conv_25_ptr);
14259                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
14260                 FREE(untag_ptr(ret_conv_25));
14261                 ret_constr.data[z] = ret_conv_25_conv;
14262         }
14263         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14264         if (get_jenv_res == JNI_EDETACHED) {
14265                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14266         }
14267         return ret_constr;
14268 }
14269 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
14270         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
14271         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14272         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
14273 }
14274 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14275         jclass c = (*env)->GetObjectClass(env, o);
14276         CHECK(c != NULL);
14277         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
14278         atomic_init(&calls->refcnt, 1);
14279         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14280         calls->o = (*env)->NewWeakGlobalRef(env, o);
14281         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
14282         CHECK(calls->handle_custom_message_meth != NULL);
14283         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
14284         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
14285
14286         LDKCustomMessageHandler ret = {
14287                 .this_arg = (void*) calls,
14288                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
14289                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
14290                 .free = LDKCustomMessageHandler_JCalls_free,
14291                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
14292         };
14293         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
14294         return ret;
14295 }
14296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14297         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
14298         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
14299         return tag_ptr(res_ptr, true);
14300 }
14301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
14302         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
14303         return tag_ptr(&inp->CustomMessageReader, false);
14304 }
14305 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) {
14306         void* this_arg_ptr = untag_ptr(this_arg);
14307         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14308         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14309         void* msg_ptr = untag_ptr(msg);
14310         CHECK_ACCESS(msg_ptr);
14311         LDKType msg_conv = *(LDKType*)(msg_ptr);
14312         if (msg_conv.free == LDKType_JCalls_free) {
14313                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14314                 LDKType_JCalls_cloned(&msg_conv);
14315         }
14316         LDKPublicKey sender_node_id_ref;
14317         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
14318         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
14319         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14320         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
14321         return tag_ptr(ret_conv, true);
14322 }
14323
14324 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
14325         void* this_arg_ptr = untag_ptr(this_arg);
14326         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14327         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14328         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
14329         int64_tArray ret_arr = NULL;
14330         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14331         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14332         for (size_t z = 0; z < ret_var.datalen; z++) {
14333                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
14334                 *ret_conv_25_conv = ret_var.data[z];
14335                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
14336         }
14337         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14338         FREE(ret_var.data);
14339         return ret_arr;
14340 }
14341
14342 typedef struct LDKCustomOnionMessageHandler_JCalls {
14343         atomic_size_t refcnt;
14344         JavaVM *vm;
14345         jweak o;
14346         jmethodID handle_custom_message_meth;
14347         jmethodID read_custom_message_meth;
14348 } LDKCustomOnionMessageHandler_JCalls;
14349 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
14350         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14351         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14352                 JNIEnv *env;
14353                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14354                 if (get_jenv_res == JNI_EDETACHED) {
14355                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14356                 } else {
14357                         DO_ASSERT(get_jenv_res == JNI_OK);
14358                 }
14359                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14360                 if (get_jenv_res == JNI_EDETACHED) {
14361                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14362                 }
14363                 FREE(j_calls);
14364         }
14365 }
14366 void handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKCustomOnionMessageContents msg) {
14367         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14368         JNIEnv *env;
14369         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14370         if (get_jenv_res == JNI_EDETACHED) {
14371                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14372         } else {
14373                 DO_ASSERT(get_jenv_res == JNI_OK);
14374         }
14375         LDKCustomOnionMessageContents* msg_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
14376         *msg_ret = msg;
14377         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14378         CHECK(obj != NULL);
14379         (*env)->CallVoidMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true));
14380         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14381                 (*env)->ExceptionDescribe(env);
14382                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14383         }
14384         if (get_jenv_res == JNI_EDETACHED) {
14385                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14386         }
14387 }
14388 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
14389         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14390         JNIEnv *env;
14391         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14392         if (get_jenv_res == JNI_EDETACHED) {
14393                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14394         } else {
14395                 DO_ASSERT(get_jenv_res == JNI_OK);
14396         }
14397         int64_t message_type_conv = message_type;
14398         LDKu8slice buffer_var = buffer;
14399         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
14400         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
14401         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14402         CHECK(obj != NULL);
14403         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_custom_message_meth, message_type_conv, buffer_arr);
14404         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14405                 (*env)->ExceptionDescribe(env);
14406                 (*env)->FatalError(env, "A call to read_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14407         }
14408         void* ret_ptr = untag_ptr(ret);
14409         CHECK_ACCESS(ret_ptr);
14410         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(ret_ptr);
14411         FREE(untag_ptr(ret));
14412         if (get_jenv_res == JNI_EDETACHED) {
14413                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14414         }
14415         return ret_conv;
14416 }
14417 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
14418         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
14419         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14420 }
14421 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o) {
14422         jclass c = (*env)->GetObjectClass(env, o);
14423         CHECK(c != NULL);
14424         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
14425         atomic_init(&calls->refcnt, 1);
14426         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14427         calls->o = (*env)->NewWeakGlobalRef(env, o);
14428         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J)V");
14429         CHECK(calls->handle_custom_message_meth != NULL);
14430         calls->read_custom_message_meth = (*env)->GetMethodID(env, c, "read_custom_message", "(J[B)J");
14431         CHECK(calls->read_custom_message_meth != NULL);
14432
14433         LDKCustomOnionMessageHandler ret = {
14434                 .this_arg = (void*) calls,
14435                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
14436                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
14437                 .free = LDKCustomOnionMessageHandler_JCalls_free,
14438         };
14439         return ret;
14440 }
14441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o) {
14442         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
14443         *res_ptr = LDKCustomOnionMessageHandler_init(env, clz, o);
14444         return tag_ptr(res_ptr, true);
14445 }
14446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14447         void* this_arg_ptr = untag_ptr(this_arg);
14448         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14449         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14450         void* msg_ptr = untag_ptr(msg);
14451         CHECK_ACCESS(msg_ptr);
14452         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
14453         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
14454                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14455                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
14456         }
14457         (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
14458 }
14459
14460 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) {
14461         void* this_arg_ptr = untag_ptr(this_arg);
14462         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14463         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14464         LDKu8slice buffer_ref;
14465         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
14466         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
14467         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
14468         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
14469         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
14470         return tag_ptr(ret_conv, true);
14471 }
14472
14473 typedef struct LDKSocketDescriptor_JCalls {
14474         atomic_size_t refcnt;
14475         JavaVM *vm;
14476         jweak o;
14477         jmethodID send_data_meth;
14478         jmethodID disconnect_socket_meth;
14479         jmethodID eq_meth;
14480         jmethodID hash_meth;
14481 } LDKSocketDescriptor_JCalls;
14482 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
14483         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14484         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14485                 JNIEnv *env;
14486                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14487                 if (get_jenv_res == JNI_EDETACHED) {
14488                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14489                 } else {
14490                         DO_ASSERT(get_jenv_res == JNI_OK);
14491                 }
14492                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14493                 if (get_jenv_res == JNI_EDETACHED) {
14494                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14495                 }
14496                 FREE(j_calls);
14497         }
14498 }
14499 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
14500         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14501         JNIEnv *env;
14502         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14503         if (get_jenv_res == JNI_EDETACHED) {
14504                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14505         } else {
14506                 DO_ASSERT(get_jenv_res == JNI_OK);
14507         }
14508         LDKu8slice data_var = data;
14509         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
14510         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
14511         jboolean resume_read_conv = resume_read;
14512         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14513         CHECK(obj != NULL);
14514         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
14515         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14516                 (*env)->ExceptionDescribe(env);
14517                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
14518         }
14519         if (get_jenv_res == JNI_EDETACHED) {
14520                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14521         }
14522         return ret;
14523 }
14524 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
14525         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14526         JNIEnv *env;
14527         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14528         if (get_jenv_res == JNI_EDETACHED) {
14529                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14530         } else {
14531                 DO_ASSERT(get_jenv_res == JNI_OK);
14532         }
14533         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14534         CHECK(obj != NULL);
14535         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
14536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14537                 (*env)->ExceptionDescribe(env);
14538                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
14539         }
14540         if (get_jenv_res == JNI_EDETACHED) {
14541                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14542         }
14543 }
14544 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
14545         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14546         JNIEnv *env;
14547         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14548         if (get_jenv_res == JNI_EDETACHED) {
14549                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14550         } else {
14551                 DO_ASSERT(get_jenv_res == JNI_OK);
14552         }
14553         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14554         *other_arg_clone = SocketDescriptor_clone(other_arg);
14555         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14556         CHECK(obj != NULL);
14557         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
14558         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14559                 (*env)->ExceptionDescribe(env);
14560                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
14561         }
14562         if (get_jenv_res == JNI_EDETACHED) {
14563                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14564         }
14565         return ret;
14566 }
14567 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
14568         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14569         JNIEnv *env;
14570         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14571         if (get_jenv_res == JNI_EDETACHED) {
14572                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14573         } else {
14574                 DO_ASSERT(get_jenv_res == JNI_OK);
14575         }
14576         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14577         CHECK(obj != NULL);
14578         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
14579         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14580                 (*env)->ExceptionDescribe(env);
14581                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
14582         }
14583         if (get_jenv_res == JNI_EDETACHED) {
14584                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14585         }
14586         return ret;
14587 }
14588 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
14589         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
14590         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14591 }
14592 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
14593         jclass c = (*env)->GetObjectClass(env, o);
14594         CHECK(c != NULL);
14595         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
14596         atomic_init(&calls->refcnt, 1);
14597         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14598         calls->o = (*env)->NewWeakGlobalRef(env, o);
14599         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
14600         CHECK(calls->send_data_meth != NULL);
14601         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
14602         CHECK(calls->disconnect_socket_meth != NULL);
14603         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
14604         CHECK(calls->eq_meth != NULL);
14605         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
14606         CHECK(calls->hash_meth != NULL);
14607
14608         LDKSocketDescriptor ret = {
14609                 .this_arg = (void*) calls,
14610                 .send_data = send_data_LDKSocketDescriptor_jcall,
14611                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
14612                 .eq = eq_LDKSocketDescriptor_jcall,
14613                 .hash = hash_LDKSocketDescriptor_jcall,
14614                 .cloned = LDKSocketDescriptor_JCalls_cloned,
14615                 .free = LDKSocketDescriptor_JCalls_free,
14616         };
14617         return ret;
14618 }
14619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
14620         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14621         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
14622         return tag_ptr(res_ptr, true);
14623 }
14624 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) {
14625         void* this_arg_ptr = untag_ptr(this_arg);
14626         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14627         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14628         LDKu8slice data_ref;
14629         data_ref.datalen = (*env)->GetArrayLength(env, data);
14630         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14631         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14632         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14633         return ret_conv;
14634 }
14635
14636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14637         void* this_arg_ptr = untag_ptr(this_arg);
14638         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14639         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14640         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14641 }
14642
14643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14644         void* this_arg_ptr = untag_ptr(this_arg);
14645         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14646         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14647         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14648         return ret_conv;
14649 }
14650
14651 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14652 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14653 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14654 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14655 static jclass LDKEffectiveCapacity_Total_class = NULL;
14656 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14657 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14658 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14659 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14660 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14662         LDKEffectiveCapacity_ExactLiquidity_class =
14663                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14664         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14665         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14666         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14667         LDKEffectiveCapacity_MaximumHTLC_class =
14668                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14669         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14670         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14671         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14672         LDKEffectiveCapacity_Total_class =
14673                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14674         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14675         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14676         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14677         LDKEffectiveCapacity_Infinite_class =
14678                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14679         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14680         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14681         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14682         LDKEffectiveCapacity_Unknown_class =
14683                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14684         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14685         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14686         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14687 }
14688 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14689         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14690         switch(obj->tag) {
14691                 case LDKEffectiveCapacity_ExactLiquidity: {
14692                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14693                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14694                 }
14695                 case LDKEffectiveCapacity_MaximumHTLC: {
14696                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14697                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14698                 }
14699                 case LDKEffectiveCapacity_Total: {
14700                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14701                         int64_t htlc_maximum_msat_conv = obj->total.htlc_maximum_msat;
14702                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_conv);
14703                 }
14704                 case LDKEffectiveCapacity_Infinite: {
14705                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14706                 }
14707                 case LDKEffectiveCapacity_Unknown: {
14708                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14709                 }
14710                 default: abort();
14711         }
14712 }
14713 typedef struct LDKRouter_JCalls {
14714         atomic_size_t refcnt;
14715         JavaVM *vm;
14716         jweak o;
14717         jmethodID find_route_meth;
14718         jmethodID find_route_with_id_meth;
14719         jmethodID notify_payment_path_failed_meth;
14720         jmethodID notify_payment_path_successful_meth;
14721         jmethodID notify_payment_probe_successful_meth;
14722         jmethodID notify_payment_probe_failed_meth;
14723 } LDKRouter_JCalls;
14724 static void LDKRouter_JCalls_free(void* this_arg) {
14725         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14726         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14727                 JNIEnv *env;
14728                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14729                 if (get_jenv_res == JNI_EDETACHED) {
14730                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14731                 } else {
14732                         DO_ASSERT(get_jenv_res == JNI_OK);
14733                 }
14734                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14735                 if (get_jenv_res == JNI_EDETACHED) {
14736                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14737                 }
14738                 FREE(j_calls);
14739         }
14740 }
14741 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
14742         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14743         JNIEnv *env;
14744         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14745         if (get_jenv_res == JNI_EDETACHED) {
14746                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14747         } else {
14748                 DO_ASSERT(get_jenv_res == JNI_OK);
14749         }
14750         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14751         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14752         LDKRouteParameters route_params_var = *route_params;
14753         int64_t route_params_ref = 0;
14754         route_params_var = RouteParameters_clone(&route_params_var);
14755         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14756         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
14757         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14758         int64_tArray first_hops_arr = NULL;
14759         if (first_hops != NULL) {
14760                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14761                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14762                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14763                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14764                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14765                         int64_t first_hops_conv_16_ref = 0;
14766                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14767                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
14768                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14769                 }
14770                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14771         }
14772         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
14773         int64_t inflight_htlcs_ref = 0;
14774         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
14775         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
14776         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14777         CHECK(obj != NULL);
14778         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref);
14779         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14780                 (*env)->ExceptionDescribe(env);
14781                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14782         }
14783         void* ret_ptr = untag_ptr(ret);
14784         CHECK_ACCESS(ret_ptr);
14785         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14786         FREE(untag_ptr(ret));
14787         if (get_jenv_res == JNI_EDETACHED) {
14788                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14789         }
14790         return ret_conv;
14791 }
14792 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) {
14793         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14794         JNIEnv *env;
14795         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14796         if (get_jenv_res == JNI_EDETACHED) {
14797                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14798         } else {
14799                 DO_ASSERT(get_jenv_res == JNI_OK);
14800         }
14801         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14802         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14803         LDKRouteParameters route_params_var = *route_params;
14804         int64_t route_params_ref = 0;
14805         route_params_var = RouteParameters_clone(&route_params_var);
14806         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14807         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
14808         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14809         int64_tArray first_hops_arr = NULL;
14810         if (first_hops != NULL) {
14811                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14812                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14813                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14814                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14815                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14816                         int64_t first_hops_conv_16_ref = 0;
14817                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14818                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
14819                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14820                 }
14821                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14822         }
14823         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
14824         int64_t inflight_htlcs_ref = 0;
14825         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
14826         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
14827         int8_tArray _payment_hash_arr = (*env)->NewByteArray(env, 32);
14828         (*env)->SetByteArrayRegion(env, _payment_hash_arr, 0, 32, _payment_hash.data);
14829         int8_tArray _payment_id_arr = (*env)->NewByteArray(env, 32);
14830         (*env)->SetByteArrayRegion(env, _payment_id_arr, 0, 32, _payment_id.data);
14831         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14832         CHECK(obj != NULL);
14833         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);
14834         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14835                 (*env)->ExceptionDescribe(env);
14836                 (*env)->FatalError(env, "A call to find_route_with_id in LDKRouter from rust threw an exception.");
14837         }
14838         void* ret_ptr = untag_ptr(ret);
14839         CHECK_ACCESS(ret_ptr);
14840         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14841         FREE(untag_ptr(ret));
14842         if (get_jenv_res == JNI_EDETACHED) {
14843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14844         }
14845         return ret_conv;
14846 }
14847 void notify_payment_path_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14848         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14849         JNIEnv *env;
14850         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14851         if (get_jenv_res == JNI_EDETACHED) {
14852                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14853         } else {
14854                 DO_ASSERT(get_jenv_res == JNI_OK);
14855         }
14856         LDKCVec_RouteHopZ path_var = path;
14857         int64_tArray path_arr = NULL;
14858         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14859         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14860         for (size_t k = 0; k < path_var.datalen; k++) {
14861                 LDKRouteHop path_conv_10_var = path_var.data[k];
14862                 int64_t path_conv_10_ref = 0;
14863                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14864                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14865                 path_arr_ptr[k] = path_conv_10_ref;
14866         }
14867         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14868         FREE(path_var.data);
14869         int64_t short_channel_id_conv = short_channel_id;
14870         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14871         CHECK(obj != NULL);
14872         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_failed_meth, path_arr, short_channel_id_conv);
14873         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14874                 (*env)->ExceptionDescribe(env);
14875                 (*env)->FatalError(env, "A call to notify_payment_path_failed in LDKRouter from rust threw an exception.");
14876         }
14877         if (get_jenv_res == JNI_EDETACHED) {
14878                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14879         }
14880 }
14881 void notify_payment_path_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
14882         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14883         JNIEnv *env;
14884         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14885         if (get_jenv_res == JNI_EDETACHED) {
14886                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14887         } else {
14888                 DO_ASSERT(get_jenv_res == JNI_OK);
14889         }
14890         LDKCVec_RouteHopZ path_var = path;
14891         int64_tArray path_arr = NULL;
14892         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14893         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14894         for (size_t k = 0; k < path_var.datalen; k++) {
14895                 LDKRouteHop path_conv_10_var = path_var.data[k];
14896                 int64_t path_conv_10_ref = 0;
14897                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14898                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14899                 path_arr_ptr[k] = path_conv_10_ref;
14900         }
14901         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14902         FREE(path_var.data);
14903         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14904         CHECK(obj != NULL);
14905         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_successful_meth, path_arr);
14906         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14907                 (*env)->ExceptionDescribe(env);
14908                 (*env)->FatalError(env, "A call to notify_payment_path_successful in LDKRouter from rust threw an exception.");
14909         }
14910         if (get_jenv_res == JNI_EDETACHED) {
14911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14912         }
14913 }
14914 void notify_payment_probe_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
14915         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14916         JNIEnv *env;
14917         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14918         if (get_jenv_res == JNI_EDETACHED) {
14919                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14920         } else {
14921                 DO_ASSERT(get_jenv_res == JNI_OK);
14922         }
14923         LDKCVec_RouteHopZ path_var = path;
14924         int64_tArray path_arr = NULL;
14925         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14926         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14927         for (size_t k = 0; k < path_var.datalen; k++) {
14928                 LDKRouteHop path_conv_10_var = path_var.data[k];
14929                 int64_t path_conv_10_ref = 0;
14930                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14931                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14932                 path_arr_ptr[k] = path_conv_10_ref;
14933         }
14934         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14935         FREE(path_var.data);
14936         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14937         CHECK(obj != NULL);
14938         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_successful_meth, path_arr);
14939         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14940                 (*env)->ExceptionDescribe(env);
14941                 (*env)->FatalError(env, "A call to notify_payment_probe_successful in LDKRouter from rust threw an exception.");
14942         }
14943         if (get_jenv_res == JNI_EDETACHED) {
14944                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14945         }
14946 }
14947 void notify_payment_probe_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14948         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14949         JNIEnv *env;
14950         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14951         if (get_jenv_res == JNI_EDETACHED) {
14952                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14953         } else {
14954                 DO_ASSERT(get_jenv_res == JNI_OK);
14955         }
14956         LDKCVec_RouteHopZ path_var = path;
14957         int64_tArray path_arr = NULL;
14958         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14959         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14960         for (size_t k = 0; k < path_var.datalen; k++) {
14961                 LDKRouteHop path_conv_10_var = path_var.data[k];
14962                 int64_t path_conv_10_ref = 0;
14963                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14964                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14965                 path_arr_ptr[k] = path_conv_10_ref;
14966         }
14967         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14968         FREE(path_var.data);
14969         int64_t short_channel_id_conv = short_channel_id;
14970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14971         CHECK(obj != NULL);
14972         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_failed_meth, path_arr, short_channel_id_conv);
14973         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14974                 (*env)->ExceptionDescribe(env);
14975                 (*env)->FatalError(env, "A call to notify_payment_probe_failed in LDKRouter from rust threw an exception.");
14976         }
14977         if (get_jenv_res == JNI_EDETACHED) {
14978                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14979         }
14980 }
14981 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14982         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14983         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14984 }
14985 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14986         jclass c = (*env)->GetObjectClass(env, o);
14987         CHECK(c != NULL);
14988         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14989         atomic_init(&calls->refcnt, 1);
14990         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14991         calls->o = (*env)->NewWeakGlobalRef(env, o);
14992         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
14993         CHECK(calls->find_route_meth != NULL);
14994         calls->find_route_with_id_meth = (*env)->GetMethodID(env, c, "find_route_with_id", "([BJ[JJ[B[B)J");
14995         CHECK(calls->find_route_with_id_meth != NULL);
14996         calls->notify_payment_path_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_path_failed", "([JJ)V");
14997         CHECK(calls->notify_payment_path_failed_meth != NULL);
14998         calls->notify_payment_path_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_path_successful", "([J)V");
14999         CHECK(calls->notify_payment_path_successful_meth != NULL);
15000         calls->notify_payment_probe_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_successful", "([J)V");
15001         CHECK(calls->notify_payment_probe_successful_meth != NULL);
15002         calls->notify_payment_probe_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_failed", "([JJ)V");
15003         CHECK(calls->notify_payment_probe_failed_meth != NULL);
15004
15005         LDKRouter ret = {
15006                 .this_arg = (void*) calls,
15007                 .find_route = find_route_LDKRouter_jcall,
15008                 .find_route_with_id = find_route_with_id_LDKRouter_jcall,
15009                 .notify_payment_path_failed = notify_payment_path_failed_LDKRouter_jcall,
15010                 .notify_payment_path_successful = notify_payment_path_successful_LDKRouter_jcall,
15011                 .notify_payment_probe_successful = notify_payment_probe_successful_LDKRouter_jcall,
15012                 .notify_payment_probe_failed = notify_payment_probe_failed_LDKRouter_jcall,
15013                 .free = LDKRouter_JCalls_free,
15014         };
15015         return ret;
15016 }
15017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
15018         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
15019         *res_ptr = LDKRouter_init(env, clz, o);
15020         return tag_ptr(res_ptr, true);
15021 }
15022 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) {
15023         void* this_arg_ptr = untag_ptr(this_arg);
15024         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15025         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15026         LDKPublicKey payer_ref;
15027         CHECK((*env)->GetArrayLength(env, payer) == 33);
15028         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
15029         LDKRouteParameters route_params_conv;
15030         route_params_conv.inner = untag_ptr(route_params);
15031         route_params_conv.is_owned = ptr_is_owned(route_params);
15032         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
15033         route_params_conv.is_owned = false;
15034         LDKCVec_ChannelDetailsZ first_hops_constr;
15035         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
15036         if (first_hops != NULL) {
15037                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
15038                 if (first_hops_constr.datalen > 0)
15039                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15040                 else
15041                         first_hops_constr.data = NULL;
15042                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
15043                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
15044                         int64_t first_hops_conv_16 = first_hops_vals[q];
15045                         LDKChannelDetails first_hops_conv_16_conv;
15046                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
15047                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
15048                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
15049                         first_hops_conv_16_conv.is_owned = false;
15050                         first_hops_constr.data[q] = first_hops_conv_16_conv;
15051                 }
15052                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
15053                 first_hops_ptr = &first_hops_constr;
15054         }
15055         LDKInFlightHtlcs inflight_htlcs_conv;
15056         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
15057         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
15058         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
15059         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
15060         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15061         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv);
15062         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
15063         return tag_ptr(ret_conv, true);
15064 }
15065
15066 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) {
15067         void* this_arg_ptr = untag_ptr(this_arg);
15068         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15069         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15070         LDKPublicKey payer_ref;
15071         CHECK((*env)->GetArrayLength(env, payer) == 33);
15072         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
15073         LDKRouteParameters route_params_conv;
15074         route_params_conv.inner = untag_ptr(route_params);
15075         route_params_conv.is_owned = ptr_is_owned(route_params);
15076         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
15077         route_params_conv.is_owned = false;
15078         LDKCVec_ChannelDetailsZ first_hops_constr;
15079         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
15080         if (first_hops != NULL) {
15081                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
15082                 if (first_hops_constr.datalen > 0)
15083                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15084                 else
15085                         first_hops_constr.data = NULL;
15086                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
15087                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
15088                         int64_t first_hops_conv_16 = first_hops_vals[q];
15089                         LDKChannelDetails first_hops_conv_16_conv;
15090                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
15091                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
15092                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
15093                         first_hops_conv_16_conv.is_owned = false;
15094                         first_hops_constr.data[q] = first_hops_conv_16_conv;
15095                 }
15096                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
15097                 first_hops_ptr = &first_hops_constr;
15098         }
15099         LDKInFlightHtlcs inflight_htlcs_conv;
15100         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
15101         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
15102         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
15103         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
15104         LDKThirtyTwoBytes _payment_hash_ref;
15105         CHECK((*env)->GetArrayLength(env, _payment_hash) == 32);
15106         (*env)->GetByteArrayRegion(env, _payment_hash, 0, 32, _payment_hash_ref.data);
15107         LDKThirtyTwoBytes _payment_id_ref;
15108         CHECK((*env)->GetArrayLength(env, _payment_id) == 32);
15109         (*env)->GetByteArrayRegion(env, _payment_id, 0, 32, _payment_id_ref.data);
15110         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15111         *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);
15112         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
15113         return tag_ptr(ret_conv, true);
15114 }
15115
15116 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) {
15117         void* this_arg_ptr = untag_ptr(this_arg);
15118         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15119         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15120         LDKCVec_RouteHopZ path_constr;
15121         path_constr.datalen = (*env)->GetArrayLength(env, path);
15122         if (path_constr.datalen > 0)
15123                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15124         else
15125                 path_constr.data = NULL;
15126         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15127         for (size_t k = 0; k < path_constr.datalen; k++) {
15128                 int64_t path_conv_10 = path_vals[k];
15129                 LDKRouteHop path_conv_10_conv;
15130                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15131                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15132                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15133                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15134                 path_constr.data[k] = path_conv_10_conv;
15135         }
15136         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15137         (this_arg_conv->notify_payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15138 }
15139
15140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15141         void* this_arg_ptr = untag_ptr(this_arg);
15142         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15143         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15144         LDKCVec_RouteHopZ path_constr;
15145         path_constr.datalen = (*env)->GetArrayLength(env, path);
15146         if (path_constr.datalen > 0)
15147                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15148         else
15149                 path_constr.data = NULL;
15150         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15151         for (size_t k = 0; k < path_constr.datalen; k++) {
15152                 int64_t path_conv_10 = path_vals[k];
15153                 LDKRouteHop path_conv_10_conv;
15154                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15155                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15156                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15157                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15158                 path_constr.data[k] = path_conv_10_conv;
15159         }
15160         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15161         (this_arg_conv->notify_payment_path_successful)(this_arg_conv->this_arg, path_constr);
15162 }
15163
15164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15165         void* this_arg_ptr = untag_ptr(this_arg);
15166         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15167         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15168         LDKCVec_RouteHopZ path_constr;
15169         path_constr.datalen = (*env)->GetArrayLength(env, path);
15170         if (path_constr.datalen > 0)
15171                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15172         else
15173                 path_constr.data = NULL;
15174         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15175         for (size_t k = 0; k < path_constr.datalen; k++) {
15176                 int64_t path_conv_10 = path_vals[k];
15177                 LDKRouteHop path_conv_10_conv;
15178                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15179                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15180                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15181                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15182                 path_constr.data[k] = path_conv_10_conv;
15183         }
15184         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15185         (this_arg_conv->notify_payment_probe_successful)(this_arg_conv->this_arg, path_constr);
15186 }
15187
15188 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) {
15189         void* this_arg_ptr = untag_ptr(this_arg);
15190         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15191         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15192         LDKCVec_RouteHopZ path_constr;
15193         path_constr.datalen = (*env)->GetArrayLength(env, path);
15194         if (path_constr.datalen > 0)
15195                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15196         else
15197                 path_constr.data = NULL;
15198         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15199         for (size_t k = 0; k < path_constr.datalen; k++) {
15200                 int64_t path_conv_10 = path_vals[k];
15201                 LDKRouteHop path_conv_10_conv;
15202                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15203                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15204                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15205                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15206                 path_constr.data[k] = path_conv_10_conv;
15207         }
15208         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15209         (this_arg_conv->notify_payment_probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15210 }
15211
15212 static jclass LDKDestination_Node_class = NULL;
15213 static jmethodID LDKDestination_Node_meth = NULL;
15214 static jclass LDKDestination_BlindedPath_class = NULL;
15215 static jmethodID LDKDestination_BlindedPath_meth = NULL;
15216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
15217         LDKDestination_Node_class =
15218                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
15219         CHECK(LDKDestination_Node_class != NULL);
15220         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
15221         CHECK(LDKDestination_Node_meth != NULL);
15222         LDKDestination_BlindedPath_class =
15223                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedPath"));
15224         CHECK(LDKDestination_BlindedPath_class != NULL);
15225         LDKDestination_BlindedPath_meth = (*env)->GetMethodID(env, LDKDestination_BlindedPath_class, "<init>", "(J)V");
15226         CHECK(LDKDestination_BlindedPath_meth != NULL);
15227 }
15228 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15229         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
15230         switch(obj->tag) {
15231                 case LDKDestination_Node: {
15232                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
15233                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
15234                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
15235                 }
15236                 case LDKDestination_BlindedPath: {
15237                         LDKBlindedPath blinded_path_var = obj->blinded_path;
15238                         int64_t blinded_path_ref = 0;
15239                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_path_var);
15240                         blinded_path_ref = tag_ptr(blinded_path_var.inner, false);
15241                         return (*env)->NewObject(env, LDKDestination_BlindedPath_class, LDKDestination_BlindedPath_meth, blinded_path_ref);
15242                 }
15243                 default: abort();
15244         }
15245 }
15246 static jclass LDKOnionMessageContents_Custom_class = NULL;
15247 static jmethodID LDKOnionMessageContents_Custom_meth = NULL;
15248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKOnionMessageContents_init (JNIEnv *env, jclass clz) {
15249         LDKOnionMessageContents_Custom_class =
15250                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKOnionMessageContents$Custom"));
15251         CHECK(LDKOnionMessageContents_Custom_class != NULL);
15252         LDKOnionMessageContents_Custom_meth = (*env)->GetMethodID(env, LDKOnionMessageContents_Custom_class, "<init>", "(J)V");
15253         CHECK(LDKOnionMessageContents_Custom_meth != NULL);
15254 }
15255 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageContents_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15256         LDKOnionMessageContents *obj = (LDKOnionMessageContents*)untag_ptr(ptr);
15257         switch(obj->tag) {
15258                 case LDKOnionMessageContents_Custom: {
15259                         LDKCustomOnionMessageContents* custom_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15260                         *custom_ret = CustomOnionMessageContents_clone(&obj->custom);
15261                         return (*env)->NewObject(env, LDKOnionMessageContents_Custom_class, LDKOnionMessageContents_Custom_meth, tag_ptr(custom_ret, true));
15262                 }
15263                 default: abort();
15264         }
15265 }
15266 static jclass LDKGossipSync_P2P_class = NULL;
15267 static jmethodID LDKGossipSync_P2P_meth = NULL;
15268 static jclass LDKGossipSync_Rapid_class = NULL;
15269 static jmethodID LDKGossipSync_Rapid_meth = NULL;
15270 static jclass LDKGossipSync_None_class = NULL;
15271 static jmethodID LDKGossipSync_None_meth = NULL;
15272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
15273         LDKGossipSync_P2P_class =
15274                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
15275         CHECK(LDKGossipSync_P2P_class != NULL);
15276         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
15277         CHECK(LDKGossipSync_P2P_meth != NULL);
15278         LDKGossipSync_Rapid_class =
15279                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
15280         CHECK(LDKGossipSync_Rapid_class != NULL);
15281         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
15282         CHECK(LDKGossipSync_Rapid_meth != NULL);
15283         LDKGossipSync_None_class =
15284                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
15285         CHECK(LDKGossipSync_None_class != NULL);
15286         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
15287         CHECK(LDKGossipSync_None_meth != NULL);
15288 }
15289 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15290         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15291         switch(obj->tag) {
15292                 case LDKGossipSync_P2P: {
15293                         LDKP2PGossipSync p2p_var = obj->p2p;
15294                         int64_t p2p_ref = 0;
15295                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
15296                         p2p_ref = tag_ptr(p2p_var.inner, false);
15297                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
15298                 }
15299                 case LDKGossipSync_Rapid: {
15300                         LDKRapidGossipSync rapid_var = obj->rapid;
15301                         int64_t rapid_ref = 0;
15302                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
15303                         rapid_ref = tag_ptr(rapid_var.inner, false);
15304                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
15305                 }
15306                 case LDKGossipSync_None: {
15307                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
15308                 }
15309                 default: abort();
15310         }
15311 }
15312 static jclass LDKFallback_SegWitProgram_class = NULL;
15313 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
15314 static jclass LDKFallback_PubKeyHash_class = NULL;
15315 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
15316 static jclass LDKFallback_ScriptHash_class = NULL;
15317 static jmethodID LDKFallback_ScriptHash_meth = NULL;
15318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
15319         LDKFallback_SegWitProgram_class =
15320                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
15321         CHECK(LDKFallback_SegWitProgram_class != NULL);
15322         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
15323         CHECK(LDKFallback_SegWitProgram_meth != NULL);
15324         LDKFallback_PubKeyHash_class =
15325                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
15326         CHECK(LDKFallback_PubKeyHash_class != NULL);
15327         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
15328         CHECK(LDKFallback_PubKeyHash_meth != NULL);
15329         LDKFallback_ScriptHash_class =
15330                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
15331         CHECK(LDKFallback_ScriptHash_class != NULL);
15332         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
15333         CHECK(LDKFallback_ScriptHash_meth != NULL);
15334 }
15335 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15336         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15337         switch(obj->tag) {
15338                 case LDKFallback_SegWitProgram: {
15339                         uint8_t version_val = obj->seg_wit_program.version._0;
15340                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
15341                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
15342                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
15343                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
15344                 }
15345                 case LDKFallback_PubKeyHash: {
15346                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
15347                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
15348                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
15349                 }
15350                 case LDKFallback_ScriptHash: {
15351                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
15352                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
15353                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
15354                 }
15355                 default: abort();
15356         }
15357 }
15358 typedef struct LDKPayer_JCalls {
15359         atomic_size_t refcnt;
15360         JavaVM *vm;
15361         jweak o;
15362         jmethodID node_id_meth;
15363         jmethodID first_hops_meth;
15364         jmethodID send_payment_meth;
15365         jmethodID send_spontaneous_payment_meth;
15366         jmethodID retry_payment_meth;
15367         jmethodID abandon_payment_meth;
15368         jmethodID inflight_htlcs_meth;
15369 } LDKPayer_JCalls;
15370 static void LDKPayer_JCalls_free(void* this_arg) {
15371         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15372         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15373                 JNIEnv *env;
15374                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15375                 if (get_jenv_res == JNI_EDETACHED) {
15376                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15377                 } else {
15378                         DO_ASSERT(get_jenv_res == JNI_OK);
15379                 }
15380                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15381                 if (get_jenv_res == JNI_EDETACHED) {
15382                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15383                 }
15384                 FREE(j_calls);
15385         }
15386 }
15387 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
15388         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15389         JNIEnv *env;
15390         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15391         if (get_jenv_res == JNI_EDETACHED) {
15392                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15393         } else {
15394                 DO_ASSERT(get_jenv_res == JNI_OK);
15395         }
15396         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15397         CHECK(obj != NULL);
15398         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
15399         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15400                 (*env)->ExceptionDescribe(env);
15401                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
15402         }
15403         LDKPublicKey ret_ref;
15404         CHECK((*env)->GetArrayLength(env, ret) == 33);
15405         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
15406         if (get_jenv_res == JNI_EDETACHED) {
15407                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15408         }
15409         return ret_ref;
15410 }
15411 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
15412         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15413         JNIEnv *env;
15414         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15415         if (get_jenv_res == JNI_EDETACHED) {
15416                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15417         } else {
15418                 DO_ASSERT(get_jenv_res == JNI_OK);
15419         }
15420         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15421         CHECK(obj != NULL);
15422         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
15423         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15424                 (*env)->ExceptionDescribe(env);
15425                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
15426         }
15427         LDKCVec_ChannelDetailsZ ret_constr;
15428         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
15429         if (ret_constr.datalen > 0)
15430                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15431         else
15432                 ret_constr.data = NULL;
15433         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
15434         for (size_t q = 0; q < ret_constr.datalen; q++) {
15435                 int64_t ret_conv_16 = ret_vals[q];
15436                 LDKChannelDetails ret_conv_16_conv;
15437                 ret_conv_16_conv.inner = untag_ptr(ret_conv_16);
15438                 ret_conv_16_conv.is_owned = ptr_is_owned(ret_conv_16);
15439                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
15440                 ret_constr.data[q] = ret_conv_16_conv;
15441         }
15442         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
15443         if (get_jenv_res == JNI_EDETACHED) {
15444                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15445         }
15446         return ret_constr;
15447 }
15448 LDKCResult_NonePaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret, LDKThirtyTwoBytes payment_id) {
15449         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15450         JNIEnv *env;
15451         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15452         if (get_jenv_res == JNI_EDETACHED) {
15453                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15454         } else {
15455                 DO_ASSERT(get_jenv_res == JNI_OK);
15456         }
15457         LDKRoute route_var = *route;
15458         int64_t route_ref = 0;
15459         route_var = Route_clone(&route_var);
15460         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
15461         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
15462         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
15463         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
15464         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
15465         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
15466         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15467         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15469         CHECK(obj != NULL);
15470         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr, payment_id_arr);
15471         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15472                 (*env)->ExceptionDescribe(env);
15473                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
15474         }
15475         void* ret_ptr = untag_ptr(ret);
15476         CHECK_ACCESS(ret_ptr);
15477         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
15478         FREE(untag_ptr(ret));
15479         if (get_jenv_res == JNI_EDETACHED) {
15480                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15481         }
15482         return ret_conv;
15483 }
15484 LDKCResult_NonePaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage, LDKThirtyTwoBytes payment_id) {
15485         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15486         JNIEnv *env;
15487         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15488         if (get_jenv_res == JNI_EDETACHED) {
15489                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15490         } else {
15491                 DO_ASSERT(get_jenv_res == JNI_OK);
15492         }
15493         LDKRoute route_var = *route;
15494         int64_t route_ref = 0;
15495         route_var = Route_clone(&route_var);
15496         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
15497         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
15498         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
15499         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
15500         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15501         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15503         CHECK(obj != NULL);
15504         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr, payment_id_arr);
15505         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15506                 (*env)->ExceptionDescribe(env);
15507                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
15508         }
15509         void* ret_ptr = untag_ptr(ret);
15510         CHECK_ACCESS(ret_ptr);
15511         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
15512         FREE(untag_ptr(ret));
15513         if (get_jenv_res == JNI_EDETACHED) {
15514                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15515         }
15516         return ret_conv;
15517 }
15518 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
15519         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15520         JNIEnv *env;
15521         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15522         if (get_jenv_res == JNI_EDETACHED) {
15523                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15524         } else {
15525                 DO_ASSERT(get_jenv_res == JNI_OK);
15526         }
15527         LDKRoute route_var = *route;
15528         int64_t route_ref = 0;
15529         route_var = Route_clone(&route_var);
15530         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
15531         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
15532         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15533         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15535         CHECK(obj != NULL);
15536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
15537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15538                 (*env)->ExceptionDescribe(env);
15539                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
15540         }
15541         void* ret_ptr = untag_ptr(ret);
15542         CHECK_ACCESS(ret_ptr);
15543         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
15544         FREE(untag_ptr(ret));
15545         if (get_jenv_res == JNI_EDETACHED) {
15546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15547         }
15548         return ret_conv;
15549 }
15550 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
15551         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15552         JNIEnv *env;
15553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15554         if (get_jenv_res == JNI_EDETACHED) {
15555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15556         } else {
15557                 DO_ASSERT(get_jenv_res == JNI_OK);
15558         }
15559         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15560         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15561         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15562         CHECK(obj != NULL);
15563         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
15564         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15565                 (*env)->ExceptionDescribe(env);
15566                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
15567         }
15568         if (get_jenv_res == JNI_EDETACHED) {
15569                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15570         }
15571 }
15572 LDKInFlightHtlcs inflight_htlcs_LDKPayer_jcall(const void* this_arg) {
15573         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15574         JNIEnv *env;
15575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15576         if (get_jenv_res == JNI_EDETACHED) {
15577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15578         } else {
15579                 DO_ASSERT(get_jenv_res == JNI_OK);
15580         }
15581         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15582         CHECK(obj != NULL);
15583         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->inflight_htlcs_meth);
15584         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15585                 (*env)->ExceptionDescribe(env);
15586                 (*env)->FatalError(env, "A call to inflight_htlcs in LDKPayer from rust threw an exception.");
15587         }
15588         LDKInFlightHtlcs ret_conv;
15589         ret_conv.inner = untag_ptr(ret);
15590         ret_conv.is_owned = ptr_is_owned(ret);
15591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
15592         if (get_jenv_res == JNI_EDETACHED) {
15593                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15594         }
15595         return ret_conv;
15596 }
15597 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
15598         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
15599         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15600 }
15601 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
15602         jclass c = (*env)->GetObjectClass(env, o);
15603         CHECK(c != NULL);
15604         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
15605         atomic_init(&calls->refcnt, 1);
15606         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15607         calls->o = (*env)->NewWeakGlobalRef(env, o);
15608         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
15609         CHECK(calls->node_id_meth != NULL);
15610         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
15611         CHECK(calls->first_hops_meth != NULL);
15612         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B[B)J");
15613         CHECK(calls->send_payment_meth != NULL);
15614         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B[B)J");
15615         CHECK(calls->send_spontaneous_payment_meth != NULL);
15616         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
15617         CHECK(calls->retry_payment_meth != NULL);
15618         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
15619         CHECK(calls->abandon_payment_meth != NULL);
15620         calls->inflight_htlcs_meth = (*env)->GetMethodID(env, c, "inflight_htlcs", "()J");
15621         CHECK(calls->inflight_htlcs_meth != NULL);
15622
15623         LDKPayer ret = {
15624                 .this_arg = (void*) calls,
15625                 .node_id = node_id_LDKPayer_jcall,
15626                 .first_hops = first_hops_LDKPayer_jcall,
15627                 .send_payment = send_payment_LDKPayer_jcall,
15628                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
15629                 .retry_payment = retry_payment_LDKPayer_jcall,
15630                 .abandon_payment = abandon_payment_LDKPayer_jcall,
15631                 .inflight_htlcs = inflight_htlcs_LDKPayer_jcall,
15632                 .free = LDKPayer_JCalls_free,
15633         };
15634         return ret;
15635 }
15636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
15637         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
15638         *res_ptr = LDKPayer_init(env, clz, o);
15639         return tag_ptr(res_ptr, true);
15640 }
15641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15642         void* this_arg_ptr = untag_ptr(this_arg);
15643         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15644         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15645         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15646         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
15647         return ret_arr;
15648 }
15649
15650 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
15651         void* this_arg_ptr = untag_ptr(this_arg);
15652         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15653         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15654         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
15655         int64_tArray ret_arr = NULL;
15656         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15657         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15658         for (size_t q = 0; q < ret_var.datalen; q++) {
15659                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15660                 int64_t ret_conv_16_ref = 0;
15661                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
15662                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
15663                 ret_arr_ptr[q] = ret_conv_16_ref;
15664         }
15665         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15666         FREE(ret_var.data);
15667         return ret_arr;
15668 }
15669
15670 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) {
15671         void* this_arg_ptr = untag_ptr(this_arg);
15672         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15673         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15674         LDKRoute route_conv;
15675         route_conv.inner = untag_ptr(route);
15676         route_conv.is_owned = ptr_is_owned(route);
15677         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
15678         route_conv.is_owned = false;
15679         LDKThirtyTwoBytes payment_hash_ref;
15680         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15681         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15682         LDKThirtyTwoBytes payment_secret_ref;
15683         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
15684         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
15685         LDKThirtyTwoBytes payment_id_ref;
15686         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15687         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15688         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15689         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref, payment_id_ref);
15690         return tag_ptr(ret_conv, true);
15691 }
15692
15693 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) {
15694         void* this_arg_ptr = untag_ptr(this_arg);
15695         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15696         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15697         LDKRoute route_conv;
15698         route_conv.inner = untag_ptr(route);
15699         route_conv.is_owned = ptr_is_owned(route);
15700         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
15701         route_conv.is_owned = false;
15702         LDKThirtyTwoBytes payment_preimage_ref;
15703         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15704         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15705         LDKThirtyTwoBytes payment_id_ref;
15706         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15707         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15708         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15709         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref, payment_id_ref);
15710         return tag_ptr(ret_conv, true);
15711 }
15712
15713 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) {
15714         void* this_arg_ptr = untag_ptr(this_arg);
15715         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15716         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15717         LDKRoute route_conv;
15718         route_conv.inner = untag_ptr(route);
15719         route_conv.is_owned = ptr_is_owned(route);
15720         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
15721         route_conv.is_owned = false;
15722         LDKThirtyTwoBytes payment_id_ref;
15723         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15724         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15725         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15726         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
15727         return tag_ptr(ret_conv, true);
15728 }
15729
15730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
15731         void* this_arg_ptr = untag_ptr(this_arg);
15732         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15733         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15734         LDKThirtyTwoBytes payment_id_ref;
15735         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15736         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15737         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
15738 }
15739
15740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
15741         void* this_arg_ptr = untag_ptr(this_arg);
15742         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15743         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15744         LDKInFlightHtlcs ret_var = (this_arg_conv->inflight_htlcs)(this_arg_conv->this_arg);
15745         int64_t ret_ref = 0;
15746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
15747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
15748         return ret_ref;
15749 }
15750
15751 static jclass LDKRetry_Attempts_class = NULL;
15752 static jmethodID LDKRetry_Attempts_meth = NULL;
15753 static jclass LDKRetry_Timeout_class = NULL;
15754 static jmethodID LDKRetry_Timeout_meth = NULL;
15755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
15756         LDKRetry_Attempts_class =
15757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
15758         CHECK(LDKRetry_Attempts_class != NULL);
15759         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
15760         CHECK(LDKRetry_Attempts_meth != NULL);
15761         LDKRetry_Timeout_class =
15762                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
15763         CHECK(LDKRetry_Timeout_class != NULL);
15764         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
15765         CHECK(LDKRetry_Timeout_meth != NULL);
15766 }
15767 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15768         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
15769         switch(obj->tag) {
15770                 case LDKRetry_Attempts: {
15771                         int64_t attempts_conv = obj->attempts;
15772                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
15773                 }
15774                 case LDKRetry_Timeout: {
15775                         int64_t timeout_conv = obj->timeout;
15776                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
15777                 }
15778                 default: abort();
15779         }
15780 }
15781 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15782         LDKStr ret_str = _ldk_get_compiled_version();
15783         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15784         Str_free(ret_str);
15785         return ret_conv;
15786 }
15787
15788 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15789         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15790         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15791         Str_free(ret_str);
15792         return ret_conv;
15793 }
15794
15795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1le_1bytes(JNIEnv *env, jclass clz, int8_tArray val) {
15796         LDKU128 val_ref;
15797         CHECK((*env)->GetArrayLength(env, val) == 16);
15798         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
15799         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
15800         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_le_bytes(val_ref).data);
15801         return ret_arr;
15802 }
15803
15804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1new(JNIEnv *env, jclass clz, int8_tArray le_bytes) {
15805         LDKSixteenBytes le_bytes_ref;
15806         CHECK((*env)->GetArrayLength(env, le_bytes) == 16);
15807         (*env)->GetByteArrayRegion(env, le_bytes, 0, 16, le_bytes_ref.data);
15808         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
15809         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_new(le_bytes_ref).le_bytes);
15810         return ret_arr;
15811 }
15812
15813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
15814         LDKThirtyTwoBytes big_endian_bytes_ref;
15815         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
15816         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
15817         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15818         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15819         return tag_ptr(ret_ref, true);
15820 }
15821
15822 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15823         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15824         *ret_copy = Bech32Error_clone(arg);
15825         int64_t ret_ref = tag_ptr(ret_copy, true);
15826         return ret_ref;
15827 }
15828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15829         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15830         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15831         return ret_conv;
15832 }
15833
15834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15835         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15836         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15837         *ret_copy = Bech32Error_clone(orig_conv);
15838         int64_t ret_ref = tag_ptr(ret_copy, true);
15839         return ret_ref;
15840 }
15841
15842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
15843         if (!ptr_is_owned(o)) return;
15844         void* o_ptr = untag_ptr(o);
15845         CHECK_ACCESS(o_ptr);
15846         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15847         FREE(untag_ptr(o));
15848         Bech32Error_free(o_conv);
15849 }
15850
15851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15852         LDKTransaction _res_ref;
15853         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15854         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15855         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15856         _res_ref.data_is_owned = true;
15857         Transaction_free(_res_ref);
15858 }
15859
15860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Witness_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15861         LDKWitness _res_ref;
15862         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15863         _res_ref.data = MALLOC(_res_ref.datalen, "LDKWitness Bytes");
15864         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15865         _res_ref.data_is_owned = true;
15866         Witness_free(_res_ref);
15867 }
15868
15869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
15870         LDKCVec_u8Z script_pubkey_ref;
15871         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
15872         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15873         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
15874         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15875         *ret_ref = TxOut_new(script_pubkey_ref, value);
15876         return tag_ptr(ret_ref, true);
15877 }
15878
15879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
15880         if (!ptr_is_owned(_res)) return;
15881         void* _res_ptr = untag_ptr(_res);
15882         CHECK_ACCESS(_res_ptr);
15883         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15884         FREE(untag_ptr(_res));
15885         TxOut_free(_res_conv);
15886 }
15887
15888 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15889         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15890         *ret_ref = TxOut_clone(arg);
15891         return tag_ptr(ret_ref, true);
15892 }
15893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15894         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15895         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15896         return ret_conv;
15897 }
15898
15899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15900         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15901         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15902         *ret_ref = TxOut_clone(orig_conv);
15903         return tag_ptr(ret_ref, true);
15904 }
15905
15906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
15907         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15908         Str_free(dummy);
15909 }
15910
15911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1some(JNIEnv *env, jclass clz, jclass o) {
15912         LDKHTLCClaim o_conv = LDKHTLCClaim_from_java(env, o);
15913         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
15914         *ret_copy = COption_HTLCClaimZ_some(o_conv);
15915         int64_t ret_ref = tag_ptr(ret_copy, true);
15916         return ret_ref;
15917 }
15918
15919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1none(JNIEnv *env, jclass clz) {
15920         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
15921         *ret_copy = COption_HTLCClaimZ_none();
15922         int64_t ret_ref = tag_ptr(ret_copy, true);
15923         return ret_ref;
15924 }
15925
15926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15927         if (!ptr_is_owned(_res)) return;
15928         void* _res_ptr = untag_ptr(_res);
15929         CHECK_ACCESS(_res_ptr);
15930         LDKCOption_HTLCClaimZ _res_conv = *(LDKCOption_HTLCClaimZ*)(_res_ptr);
15931         FREE(untag_ptr(_res));
15932         COption_HTLCClaimZ_free(_res_conv);
15933 }
15934
15935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
15936         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15937         *ret_conv = CResult_NoneNoneZ_ok();
15938         return tag_ptr(ret_conv, true);
15939 }
15940
15941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
15942         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15943         *ret_conv = CResult_NoneNoneZ_err();
15944         return tag_ptr(ret_conv, true);
15945 }
15946
15947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15948         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
15949         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
15950         return ret_conv;
15951 }
15952
15953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15954         if (!ptr_is_owned(_res)) return;
15955         void* _res_ptr = untag_ptr(_res);
15956         CHECK_ACCESS(_res_ptr);
15957         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
15958         FREE(untag_ptr(_res));
15959         CResult_NoneNoneZ_free(_res_conv);
15960 }
15961
15962 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
15963         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15964         *ret_conv = CResult_NoneNoneZ_clone(arg);
15965         return tag_ptr(ret_conv, true);
15966 }
15967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15968         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
15969         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
15970         return ret_conv;
15971 }
15972
15973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15974         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
15975         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15976         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
15977         return tag_ptr(ret_conv, true);
15978 }
15979
15980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15981         LDKCounterpartyCommitmentSecrets o_conv;
15982         o_conv.inner = untag_ptr(o);
15983         o_conv.is_owned = ptr_is_owned(o);
15984         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15985         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
15986         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15987         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
15988         return tag_ptr(ret_conv, true);
15989 }
15990
15991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15992         void* e_ptr = untag_ptr(e);
15993         CHECK_ACCESS(e_ptr);
15994         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15995         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15996         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15997         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
15998         return tag_ptr(ret_conv, true);
15999 }
16000
16001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16002         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
16003         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
16004         return ret_conv;
16005 }
16006
16007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16008         if (!ptr_is_owned(_res)) return;
16009         void* _res_ptr = untag_ptr(_res);
16010         CHECK_ACCESS(_res_ptr);
16011         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
16012         FREE(untag_ptr(_res));
16013         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
16014 }
16015
16016 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
16017         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16018         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
16019         return tag_ptr(ret_conv, true);
16020 }
16021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16022         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
16023         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
16024         return ret_conv;
16025 }
16026
16027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16028         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
16029         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16030         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
16031         return tag_ptr(ret_conv, true);
16032 }
16033
16034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16035         LDKTxCreationKeys o_conv;
16036         o_conv.inner = untag_ptr(o);
16037         o_conv.is_owned = ptr_is_owned(o);
16038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16039         o_conv = TxCreationKeys_clone(&o_conv);
16040         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16041         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
16042         return tag_ptr(ret_conv, true);
16043 }
16044
16045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16046         void* e_ptr = untag_ptr(e);
16047         CHECK_ACCESS(e_ptr);
16048         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16049         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16050         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16051         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
16052         return tag_ptr(ret_conv, true);
16053 }
16054
16055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16056         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
16057         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
16058         return ret_conv;
16059 }
16060
16061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16062         if (!ptr_is_owned(_res)) return;
16063         void* _res_ptr = untag_ptr(_res);
16064         CHECK_ACCESS(_res_ptr);
16065         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
16066         FREE(untag_ptr(_res));
16067         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
16068 }
16069
16070 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
16071         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16072         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
16073         return tag_ptr(ret_conv, true);
16074 }
16075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16076         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
16077         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
16078         return ret_conv;
16079 }
16080
16081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16082         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
16083         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16084         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
16085         return tag_ptr(ret_conv, true);
16086 }
16087
16088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16089         LDKChannelPublicKeys o_conv;
16090         o_conv.inner = untag_ptr(o);
16091         o_conv.is_owned = ptr_is_owned(o);
16092         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16093         o_conv = ChannelPublicKeys_clone(&o_conv);
16094         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16095         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
16096         return tag_ptr(ret_conv, true);
16097 }
16098
16099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16100         void* e_ptr = untag_ptr(e);
16101         CHECK_ACCESS(e_ptr);
16102         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16103         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16104         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16105         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
16106         return tag_ptr(ret_conv, true);
16107 }
16108
16109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16110         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
16111         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
16112         return ret_conv;
16113 }
16114
16115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16116         if (!ptr_is_owned(_res)) return;
16117         void* _res_ptr = untag_ptr(_res);
16118         CHECK_ACCESS(_res_ptr);
16119         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
16120         FREE(untag_ptr(_res));
16121         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
16122 }
16123
16124 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
16125         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16126         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
16127         return tag_ptr(ret_conv, true);
16128 }
16129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16130         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
16131         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
16132         return ret_conv;
16133 }
16134
16135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16136         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
16137         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16138         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
16139         return tag_ptr(ret_conv, true);
16140 }
16141
16142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
16143         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16144         *ret_copy = COption_u32Z_some(o);
16145         int64_t ret_ref = tag_ptr(ret_copy, true);
16146         return ret_ref;
16147 }
16148
16149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
16150         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16151         *ret_copy = COption_u32Z_none();
16152         int64_t ret_ref = tag_ptr(ret_copy, true);
16153         return ret_ref;
16154 }
16155
16156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16157         if (!ptr_is_owned(_res)) return;
16158         void* _res_ptr = untag_ptr(_res);
16159         CHECK_ACCESS(_res_ptr);
16160         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
16161         FREE(untag_ptr(_res));
16162         COption_u32Z_free(_res_conv);
16163 }
16164
16165 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
16166         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16167         *ret_copy = COption_u32Z_clone(arg);
16168         int64_t ret_ref = tag_ptr(ret_copy, true);
16169         return ret_ref;
16170 }
16171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16172         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
16173         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
16174         return ret_conv;
16175 }
16176
16177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16178         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
16179         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16180         *ret_copy = COption_u32Z_clone(orig_conv);
16181         int64_t ret_ref = tag_ptr(ret_copy, true);
16182         return ret_ref;
16183 }
16184
16185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16186         LDKHTLCOutputInCommitment o_conv;
16187         o_conv.inner = untag_ptr(o);
16188         o_conv.is_owned = ptr_is_owned(o);
16189         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16190         o_conv = HTLCOutputInCommitment_clone(&o_conv);
16191         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16192         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
16193         return tag_ptr(ret_conv, true);
16194 }
16195
16196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16197         void* e_ptr = untag_ptr(e);
16198         CHECK_ACCESS(e_ptr);
16199         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16200         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16201         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16202         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
16203         return tag_ptr(ret_conv, true);
16204 }
16205
16206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16207         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
16208         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
16209         return ret_conv;
16210 }
16211
16212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16213         if (!ptr_is_owned(_res)) return;
16214         void* _res_ptr = untag_ptr(_res);
16215         CHECK_ACCESS(_res_ptr);
16216         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
16217         FREE(untag_ptr(_res));
16218         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
16219 }
16220
16221 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
16222         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16223         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
16224         return tag_ptr(ret_conv, true);
16225 }
16226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16227         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
16228         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
16229         return ret_conv;
16230 }
16231
16232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16233         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
16234         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16235         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
16236         return tag_ptr(ret_conv, true);
16237 }
16238
16239 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
16240         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
16241         return ret_conv;
16242 }
16243
16244 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
16245         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
16246         return ret_conv;
16247 }
16248
16249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
16250         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
16251         COption_NoneZ_free(_res_conv);
16252 }
16253
16254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16255         LDKCounterpartyChannelTransactionParameters o_conv;
16256         o_conv.inner = untag_ptr(o);
16257         o_conv.is_owned = ptr_is_owned(o);
16258         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16259         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
16260         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16261         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16262         return tag_ptr(ret_conv, true);
16263 }
16264
16265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16266         void* e_ptr = untag_ptr(e);
16267         CHECK_ACCESS(e_ptr);
16268         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16269         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16270         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16271         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
16272         return tag_ptr(ret_conv, true);
16273 }
16274
16275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16276         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16277         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16278         return ret_conv;
16279 }
16280
16281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16282         if (!ptr_is_owned(_res)) return;
16283         void* _res_ptr = untag_ptr(_res);
16284         CHECK_ACCESS(_res_ptr);
16285         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16286         FREE(untag_ptr(_res));
16287         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16288 }
16289
16290 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16291         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16292         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
16293         return tag_ptr(ret_conv, true);
16294 }
16295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16296         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16297         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16298         return ret_conv;
16299 }
16300
16301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16302         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16303         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16304         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16305         return tag_ptr(ret_conv, true);
16306 }
16307
16308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16309         LDKChannelTransactionParameters o_conv;
16310         o_conv.inner = untag_ptr(o);
16311         o_conv.is_owned = ptr_is_owned(o);
16312         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16313         o_conv = ChannelTransactionParameters_clone(&o_conv);
16314         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16315         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16316         return tag_ptr(ret_conv, true);
16317 }
16318
16319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16320         void* e_ptr = untag_ptr(e);
16321         CHECK_ACCESS(e_ptr);
16322         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16323         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16324         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16325         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
16326         return tag_ptr(ret_conv, true);
16327 }
16328
16329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16330         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16331         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16332         return ret_conv;
16333 }
16334
16335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16336         if (!ptr_is_owned(_res)) return;
16337         void* _res_ptr = untag_ptr(_res);
16338         CHECK_ACCESS(_res_ptr);
16339         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16340         FREE(untag_ptr(_res));
16341         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16342 }
16343
16344 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16345         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16346         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
16347         return tag_ptr(ret_conv, true);
16348 }
16349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16350         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16351         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16352         return ret_conv;
16353 }
16354
16355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16356         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16357         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16358         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16359         return tag_ptr(ret_conv, true);
16360 }
16361
16362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16363         LDKCVec_SignatureZ _res_constr;
16364         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16365         if (_res_constr.datalen > 0)
16366                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16367         else
16368                 _res_constr.data = NULL;
16369         for (size_t i = 0; i < _res_constr.datalen; i++) {
16370                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16371                 LDKSignature _res_conv_8_ref;
16372                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
16373                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
16374                 _res_constr.data[i] = _res_conv_8_ref;
16375         }
16376         CVec_SignatureZ_free(_res_constr);
16377 }
16378
16379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16380         LDKHolderCommitmentTransaction o_conv;
16381         o_conv.inner = untag_ptr(o);
16382         o_conv.is_owned = ptr_is_owned(o);
16383         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16384         o_conv = HolderCommitmentTransaction_clone(&o_conv);
16385         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16386         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
16387         return tag_ptr(ret_conv, true);
16388 }
16389
16390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16391         void* e_ptr = untag_ptr(e);
16392         CHECK_ACCESS(e_ptr);
16393         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16394         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16395         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16396         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
16397         return tag_ptr(ret_conv, true);
16398 }
16399
16400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16401         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16402         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16403         return ret_conv;
16404 }
16405
16406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16407         if (!ptr_is_owned(_res)) return;
16408         void* _res_ptr = untag_ptr(_res);
16409         CHECK_ACCESS(_res_ptr);
16410         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16411         FREE(untag_ptr(_res));
16412         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
16413 }
16414
16415 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16416         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16417         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
16418         return tag_ptr(ret_conv, true);
16419 }
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16421         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16422         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16423         return ret_conv;
16424 }
16425
16426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16427         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16428         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16429         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16430         return tag_ptr(ret_conv, true);
16431 }
16432
16433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16434         LDKBuiltCommitmentTransaction o_conv;
16435         o_conv.inner = untag_ptr(o);
16436         o_conv.is_owned = ptr_is_owned(o);
16437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16438         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
16439         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16440         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
16441         return tag_ptr(ret_conv, true);
16442 }
16443
16444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16445         void* e_ptr = untag_ptr(e);
16446         CHECK_ACCESS(e_ptr);
16447         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16448         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16449         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16450         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
16451         return tag_ptr(ret_conv, true);
16452 }
16453
16454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16455         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16456         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16457         return ret_conv;
16458 }
16459
16460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16461         if (!ptr_is_owned(_res)) return;
16462         void* _res_ptr = untag_ptr(_res);
16463         CHECK_ACCESS(_res_ptr);
16464         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16465         FREE(untag_ptr(_res));
16466         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
16467 }
16468
16469 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16470         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16471         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
16472         return tag_ptr(ret_conv, true);
16473 }
16474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16475         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16476         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16477         return ret_conv;
16478 }
16479
16480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16481         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16482         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16483         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16484         return tag_ptr(ret_conv, true);
16485 }
16486
16487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16488         LDKTrustedClosingTransaction o_conv;
16489         o_conv.inner = untag_ptr(o);
16490         o_conv.is_owned = ptr_is_owned(o);
16491         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16492         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
16493         
16494         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16495         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
16496         return tag_ptr(ret_conv, true);
16497 }
16498
16499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16500         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16501         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
16502         return tag_ptr(ret_conv, true);
16503 }
16504
16505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16506         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
16507         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
16508         return ret_conv;
16509 }
16510
16511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16512         if (!ptr_is_owned(_res)) return;
16513         void* _res_ptr = untag_ptr(_res);
16514         CHECK_ACCESS(_res_ptr);
16515         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
16516         FREE(untag_ptr(_res));
16517         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
16518 }
16519
16520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16521         LDKCommitmentTransaction o_conv;
16522         o_conv.inner = untag_ptr(o);
16523         o_conv.is_owned = ptr_is_owned(o);
16524         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16525         o_conv = CommitmentTransaction_clone(&o_conv);
16526         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16527         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
16528         return tag_ptr(ret_conv, true);
16529 }
16530
16531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16532         void* e_ptr = untag_ptr(e);
16533         CHECK_ACCESS(e_ptr);
16534         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16535         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16536         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16537         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
16538         return tag_ptr(ret_conv, true);
16539 }
16540
16541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16542         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16543         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16544         return ret_conv;
16545 }
16546
16547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16548         if (!ptr_is_owned(_res)) return;
16549         void* _res_ptr = untag_ptr(_res);
16550         CHECK_ACCESS(_res_ptr);
16551         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
16552         FREE(untag_ptr(_res));
16553         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
16554 }
16555
16556 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16557         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16558         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
16559         return tag_ptr(ret_conv, true);
16560 }
16561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16562         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16563         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16564         return ret_conv;
16565 }
16566
16567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16568         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16569         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16570         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
16571         return tag_ptr(ret_conv, true);
16572 }
16573
16574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16575         LDKTrustedCommitmentTransaction o_conv;
16576         o_conv.inner = untag_ptr(o);
16577         o_conv.is_owned = ptr_is_owned(o);
16578         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16579         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
16580         
16581         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16582         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
16583         return tag_ptr(ret_conv, true);
16584 }
16585
16586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16587         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16588         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
16589         return tag_ptr(ret_conv, true);
16590 }
16591
16592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16593         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
16594         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
16595         return ret_conv;
16596 }
16597
16598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16599         if (!ptr_is_owned(_res)) return;
16600         void* _res_ptr = untag_ptr(_res);
16601         CHECK_ACCESS(_res_ptr);
16602         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
16603         FREE(untag_ptr(_res));
16604         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
16605 }
16606
16607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16608         LDKCVec_SignatureZ o_constr;
16609         o_constr.datalen = (*env)->GetArrayLength(env, o);
16610         if (o_constr.datalen > 0)
16611                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16612         else
16613                 o_constr.data = NULL;
16614         for (size_t i = 0; i < o_constr.datalen; i++) {
16615                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16616                 LDKSignature o_conv_8_ref;
16617                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
16618                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
16619                 o_constr.data[i] = o_conv_8_ref;
16620         }
16621         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16622         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
16623         return tag_ptr(ret_conv, true);
16624 }
16625
16626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16627         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16628         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
16629         return tag_ptr(ret_conv, true);
16630 }
16631
16632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16633         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
16634         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
16635         return ret_conv;
16636 }
16637
16638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16639         if (!ptr_is_owned(_res)) return;
16640         void* _res_ptr = untag_ptr(_res);
16641         CHECK_ACCESS(_res_ptr);
16642         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
16643         FREE(untag_ptr(_res));
16644         CResult_CVec_SignatureZNoneZ_free(_res_conv);
16645 }
16646
16647 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
16648         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16649         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
16650         return tag_ptr(ret_conv, true);
16651 }
16652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16653         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
16654         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
16655         return ret_conv;
16656 }
16657
16658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16659         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
16660         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16661         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
16662         return tag_ptr(ret_conv, true);
16663 }
16664
16665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16666         LDKShutdownScript o_conv;
16667         o_conv.inner = untag_ptr(o);
16668         o_conv.is_owned = ptr_is_owned(o);
16669         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16670         o_conv = ShutdownScript_clone(&o_conv);
16671         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16672         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
16673         return tag_ptr(ret_conv, true);
16674 }
16675
16676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16677         void* e_ptr = untag_ptr(e);
16678         CHECK_ACCESS(e_ptr);
16679         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16680         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16681         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16682         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
16683         return tag_ptr(ret_conv, true);
16684 }
16685
16686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16687         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
16688         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
16689         return ret_conv;
16690 }
16691
16692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16693         if (!ptr_is_owned(_res)) return;
16694         void* _res_ptr = untag_ptr(_res);
16695         CHECK_ACCESS(_res_ptr);
16696         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
16697         FREE(untag_ptr(_res));
16698         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
16699 }
16700
16701 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
16702         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16703         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
16704         return tag_ptr(ret_conv, true);
16705 }
16706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16707         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
16708         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
16709         return ret_conv;
16710 }
16711
16712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16713         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
16714         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16715         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
16716         return tag_ptr(ret_conv, true);
16717 }
16718
16719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16720         LDKShutdownScript o_conv;
16721         o_conv.inner = untag_ptr(o);
16722         o_conv.is_owned = ptr_is_owned(o);
16723         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16724         o_conv = ShutdownScript_clone(&o_conv);
16725         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16726         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
16727         return tag_ptr(ret_conv, true);
16728 }
16729
16730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16731         LDKInvalidShutdownScript e_conv;
16732         e_conv.inner = untag_ptr(e);
16733         e_conv.is_owned = ptr_is_owned(e);
16734         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16735         e_conv = InvalidShutdownScript_clone(&e_conv);
16736         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16737         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
16738         return tag_ptr(ret_conv, true);
16739 }
16740
16741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16742         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
16743         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
16744         return ret_conv;
16745 }
16746
16747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16748         if (!ptr_is_owned(_res)) return;
16749         void* _res_ptr = untag_ptr(_res);
16750         CHECK_ACCESS(_res_ptr);
16751         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
16752         FREE(untag_ptr(_res));
16753         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
16754 }
16755
16756 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
16757         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16758         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
16759         return tag_ptr(ret_conv, true);
16760 }
16761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16762         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
16763         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
16764         return ret_conv;
16765 }
16766
16767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16768         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
16769         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16770         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
16771         return tag_ptr(ret_conv, true);
16772 }
16773
16774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16775         LDKCVec_PublicKeyZ _res_constr;
16776         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16777         if (_res_constr.datalen > 0)
16778                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16779         else
16780                 _res_constr.data = NULL;
16781         for (size_t i = 0; i < _res_constr.datalen; i++) {
16782                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16783                 LDKPublicKey _res_conv_8_ref;
16784                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16785                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16786                 _res_constr.data[i] = _res_conv_8_ref;
16787         }
16788         CVec_PublicKeyZ_free(_res_constr);
16789 }
16790
16791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16792         LDKBlindedPath o_conv;
16793         o_conv.inner = untag_ptr(o);
16794         o_conv.is_owned = ptr_is_owned(o);
16795         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16796         o_conv = BlindedPath_clone(&o_conv);
16797         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16798         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
16799         return tag_ptr(ret_conv, true);
16800 }
16801
16802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1err(JNIEnv *env, jclass clz) {
16803         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16804         *ret_conv = CResult_BlindedPathNoneZ_err();
16805         return tag_ptr(ret_conv, true);
16806 }
16807
16808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16809         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
16810         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
16811         return ret_conv;
16812 }
16813
16814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16815         if (!ptr_is_owned(_res)) return;
16816         void* _res_ptr = untag_ptr(_res);
16817         CHECK_ACCESS(_res_ptr);
16818         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
16819         FREE(untag_ptr(_res));
16820         CResult_BlindedPathNoneZ_free(_res_conv);
16821 }
16822
16823 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
16824         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16825         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
16826         return tag_ptr(ret_conv, true);
16827 }
16828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16829         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
16830         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
16831         return ret_conv;
16832 }
16833
16834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16835         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
16836         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16837         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
16838         return tag_ptr(ret_conv, true);
16839 }
16840
16841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16842         LDKBlindedPath o_conv;
16843         o_conv.inner = untag_ptr(o);
16844         o_conv.is_owned = ptr_is_owned(o);
16845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16846         o_conv = BlindedPath_clone(&o_conv);
16847         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16848         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
16849         return tag_ptr(ret_conv, true);
16850 }
16851
16852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16853         void* e_ptr = untag_ptr(e);
16854         CHECK_ACCESS(e_ptr);
16855         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16856         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16857         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16858         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
16859         return tag_ptr(ret_conv, true);
16860 }
16861
16862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16863         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
16864         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
16865         return ret_conv;
16866 }
16867
16868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16869         if (!ptr_is_owned(_res)) return;
16870         void* _res_ptr = untag_ptr(_res);
16871         CHECK_ACCESS(_res_ptr);
16872         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
16873         FREE(untag_ptr(_res));
16874         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
16875 }
16876
16877 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
16878         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16879         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
16880         return tag_ptr(ret_conv, true);
16881 }
16882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16883         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
16884         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
16885         return ret_conv;
16886 }
16887
16888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16889         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
16890         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16891         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
16892         return tag_ptr(ret_conv, true);
16893 }
16894
16895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16896         LDKBlindedHop o_conv;
16897         o_conv.inner = untag_ptr(o);
16898         o_conv.is_owned = ptr_is_owned(o);
16899         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16900         o_conv = BlindedHop_clone(&o_conv);
16901         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16902         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
16903         return tag_ptr(ret_conv, true);
16904 }
16905
16906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16907         void* e_ptr = untag_ptr(e);
16908         CHECK_ACCESS(e_ptr);
16909         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16910         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16911         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16912         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
16913         return tag_ptr(ret_conv, true);
16914 }
16915
16916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16917         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
16918         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
16919         return ret_conv;
16920 }
16921
16922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16923         if (!ptr_is_owned(_res)) return;
16924         void* _res_ptr = untag_ptr(_res);
16925         CHECK_ACCESS(_res_ptr);
16926         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
16927         FREE(untag_ptr(_res));
16928         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
16929 }
16930
16931 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
16932         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16933         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
16934         return tag_ptr(ret_conv, true);
16935 }
16936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16937         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
16938         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
16939         return ret_conv;
16940 }
16941
16942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16943         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
16944         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16945         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
16946         return tag_ptr(ret_conv, true);
16947 }
16948
16949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16950         void* o_ptr = untag_ptr(o);
16951         CHECK_ACCESS(o_ptr);
16952         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
16953         if (o_conv.free == LDKWriteableScore_JCalls_free) {
16954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16955                 LDKWriteableScore_JCalls_cloned(&o_conv);
16956         }
16957         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16958         *ret_copy = COption_WriteableScoreZ_some(o_conv);
16959         int64_t ret_ref = tag_ptr(ret_copy, true);
16960         return ret_ref;
16961 }
16962
16963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
16964         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16965         *ret_copy = COption_WriteableScoreZ_none();
16966         int64_t ret_ref = tag_ptr(ret_copy, true);
16967         return ret_ref;
16968 }
16969
16970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16971         if (!ptr_is_owned(_res)) return;
16972         void* _res_ptr = untag_ptr(_res);
16973         CHECK_ACCESS(_res_ptr);
16974         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
16975         FREE(untag_ptr(_res));
16976         COption_WriteableScoreZ_free(_res_conv);
16977 }
16978
16979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
16980         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16981         *ret_conv = CResult_NoneErrorZ_ok();
16982         return tag_ptr(ret_conv, true);
16983 }
16984
16985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16986         LDKIOError e_conv = LDKIOError_from_java(env, e);
16987         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16988         *ret_conv = CResult_NoneErrorZ_err(e_conv);
16989         return tag_ptr(ret_conv, true);
16990 }
16991
16992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16993         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
16994         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
16995         return ret_conv;
16996 }
16997
16998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16999         if (!ptr_is_owned(_res)) return;
17000         void* _res_ptr = untag_ptr(_res);
17001         CHECK_ACCESS(_res_ptr);
17002         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
17003         FREE(untag_ptr(_res));
17004         CResult_NoneErrorZ_free(_res_conv);
17005 }
17006
17007 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
17008         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17009         *ret_conv = CResult_NoneErrorZ_clone(arg);
17010         return tag_ptr(ret_conv, true);
17011 }
17012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17013         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
17014         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
17015         return ret_conv;
17016 }
17017
17018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17019         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
17020         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17021         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
17022         return tag_ptr(ret_conv, true);
17023 }
17024
17025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17026         LDKCVec_ChannelDetailsZ _res_constr;
17027         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17028         if (_res_constr.datalen > 0)
17029                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17030         else
17031                 _res_constr.data = NULL;
17032         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17033         for (size_t q = 0; q < _res_constr.datalen; q++) {
17034                 int64_t _res_conv_16 = _res_vals[q];
17035                 LDKChannelDetails _res_conv_16_conv;
17036                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17037                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17038                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17039                 _res_constr.data[q] = _res_conv_16_conv;
17040         }
17041         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17042         CVec_ChannelDetailsZ_free(_res_constr);
17043 }
17044
17045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17046         LDKRoute o_conv;
17047         o_conv.inner = untag_ptr(o);
17048         o_conv.is_owned = ptr_is_owned(o);
17049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17050         o_conv = Route_clone(&o_conv);
17051         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17052         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17053         return tag_ptr(ret_conv, true);
17054 }
17055
17056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17057         LDKLightningError e_conv;
17058         e_conv.inner = untag_ptr(e);
17059         e_conv.is_owned = ptr_is_owned(e);
17060         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17061         e_conv = LightningError_clone(&e_conv);
17062         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17063         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17064         return tag_ptr(ret_conv, true);
17065 }
17066
17067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17068         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17069         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17070         return ret_conv;
17071 }
17072
17073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17074         if (!ptr_is_owned(_res)) return;
17075         void* _res_ptr = untag_ptr(_res);
17076         CHECK_ACCESS(_res_ptr);
17077         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17078         FREE(untag_ptr(_res));
17079         CResult_RouteLightningErrorZ_free(_res_conv);
17080 }
17081
17082 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17083         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17084         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17085         return tag_ptr(ret_conv, true);
17086 }
17087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17088         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17089         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17090         return ret_conv;
17091 }
17092
17093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17094         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17095         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17096         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17097         return tag_ptr(ret_conv, true);
17098 }
17099
17100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17101         LDKCVec_RouteHopZ _res_constr;
17102         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17103         if (_res_constr.datalen > 0)
17104                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17105         else
17106                 _res_constr.data = NULL;
17107         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17108         for (size_t k = 0; k < _res_constr.datalen; k++) {
17109                 int64_t _res_conv_10 = _res_vals[k];
17110                 LDKRouteHop _res_conv_10_conv;
17111                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
17112                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
17113                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
17114                 _res_constr.data[k] = _res_conv_10_conv;
17115         }
17116         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17117         CVec_RouteHopZ_free(_res_constr);
17118 }
17119
17120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
17121         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17122         *ret_copy = COption_u64Z_some(o);
17123         int64_t ret_ref = tag_ptr(ret_copy, true);
17124         return ret_ref;
17125 }
17126
17127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
17128         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17129         *ret_copy = COption_u64Z_none();
17130         int64_t ret_ref = tag_ptr(ret_copy, true);
17131         return ret_ref;
17132 }
17133
17134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17135         if (!ptr_is_owned(_res)) return;
17136         void* _res_ptr = untag_ptr(_res);
17137         CHECK_ACCESS(_res_ptr);
17138         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
17139         FREE(untag_ptr(_res));
17140         COption_u64Z_free(_res_conv);
17141 }
17142
17143 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
17144         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17145         *ret_copy = COption_u64Z_clone(arg);
17146         int64_t ret_ref = tag_ptr(ret_copy, true);
17147         return ret_ref;
17148 }
17149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17150         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
17151         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
17152         return ret_conv;
17153 }
17154
17155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17156         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
17157         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17158         *ret_copy = COption_u64Z_clone(orig_conv);
17159         int64_t ret_ref = tag_ptr(ret_copy, true);
17160         return ret_ref;
17161 }
17162
17163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17164         LDKInFlightHtlcs o_conv;
17165         o_conv.inner = untag_ptr(o);
17166         o_conv.is_owned = ptr_is_owned(o);
17167         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17168         o_conv = InFlightHtlcs_clone(&o_conv);
17169         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17170         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
17171         return tag_ptr(ret_conv, true);
17172 }
17173
17174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17175         void* e_ptr = untag_ptr(e);
17176         CHECK_ACCESS(e_ptr);
17177         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17178         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17179         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17180         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
17181         return tag_ptr(ret_conv, true);
17182 }
17183
17184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17185         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
17186         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
17187         return ret_conv;
17188 }
17189
17190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17191         if (!ptr_is_owned(_res)) return;
17192         void* _res_ptr = untag_ptr(_res);
17193         CHECK_ACCESS(_res_ptr);
17194         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
17195         FREE(untag_ptr(_res));
17196         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
17197 }
17198
17199 static inline uint64_t CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR arg) {
17200         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17201         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(arg);
17202         return tag_ptr(ret_conv, true);
17203 }
17204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17205         LDKCResult_InFlightHtlcsDecodeErrorZ* arg_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(arg);
17206         int64_t ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(arg_conv);
17207         return ret_conv;
17208 }
17209
17210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17211         LDKCResult_InFlightHtlcsDecodeErrorZ* orig_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(orig);
17212         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17213         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(orig_conv);
17214         return tag_ptr(ret_conv, true);
17215 }
17216
17217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17218         LDKRouteHop o_conv;
17219         o_conv.inner = untag_ptr(o);
17220         o_conv.is_owned = ptr_is_owned(o);
17221         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17222         o_conv = RouteHop_clone(&o_conv);
17223         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17224         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
17225         return tag_ptr(ret_conv, true);
17226 }
17227
17228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17229         void* e_ptr = untag_ptr(e);
17230         CHECK_ACCESS(e_ptr);
17231         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17232         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17233         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17234         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
17235         return tag_ptr(ret_conv, true);
17236 }
17237
17238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17239         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
17240         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
17241         return ret_conv;
17242 }
17243
17244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17245         if (!ptr_is_owned(_res)) return;
17246         void* _res_ptr = untag_ptr(_res);
17247         CHECK_ACCESS(_res_ptr);
17248         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
17249         FREE(untag_ptr(_res));
17250         CResult_RouteHopDecodeErrorZ_free(_res_conv);
17251 }
17252
17253 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
17254         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17255         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
17256         return tag_ptr(ret_conv, true);
17257 }
17258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17259         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
17260         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
17261         return ret_conv;
17262 }
17263
17264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17265         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
17266         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17267         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
17268         return tag_ptr(ret_conv, true);
17269 }
17270
17271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17272         LDKCVec_CVec_RouteHopZZ _res_constr;
17273         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17274         if (_res_constr.datalen > 0)
17275                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17276         else
17277                 _res_constr.data = NULL;
17278         for (size_t m = 0; m < _res_constr.datalen; m++) {
17279                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
17280                 LDKCVec_RouteHopZ _res_conv_12_constr;
17281                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
17282                 if (_res_conv_12_constr.datalen > 0)
17283                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17284                 else
17285                         _res_conv_12_constr.data = NULL;
17286                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
17287                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
17288                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
17289                         LDKRouteHop _res_conv_12_conv_10_conv;
17290                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
17291                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
17292                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
17293                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
17294                 }
17295                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
17296                 _res_constr.data[m] = _res_conv_12_constr;
17297         }
17298         CVec_CVec_RouteHopZZ_free(_res_constr);
17299 }
17300
17301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17302         LDKRoute o_conv;
17303         o_conv.inner = untag_ptr(o);
17304         o_conv.is_owned = ptr_is_owned(o);
17305         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17306         o_conv = Route_clone(&o_conv);
17307         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17308         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
17309         return tag_ptr(ret_conv, true);
17310 }
17311
17312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17313         void* e_ptr = untag_ptr(e);
17314         CHECK_ACCESS(e_ptr);
17315         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17316         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17317         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17318         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
17319         return tag_ptr(ret_conv, true);
17320 }
17321
17322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17323         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
17324         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
17325         return ret_conv;
17326 }
17327
17328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17329         if (!ptr_is_owned(_res)) return;
17330         void* _res_ptr = untag_ptr(_res);
17331         CHECK_ACCESS(_res_ptr);
17332         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
17333         FREE(untag_ptr(_res));
17334         CResult_RouteDecodeErrorZ_free(_res_conv);
17335 }
17336
17337 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
17338         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17339         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
17340         return tag_ptr(ret_conv, true);
17341 }
17342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17343         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
17344         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
17345         return ret_conv;
17346 }
17347
17348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17349         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
17350         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17351         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
17352         return tag_ptr(ret_conv, true);
17353 }
17354
17355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17356         LDKRouteParameters o_conv;
17357         o_conv.inner = untag_ptr(o);
17358         o_conv.is_owned = ptr_is_owned(o);
17359         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17360         o_conv = RouteParameters_clone(&o_conv);
17361         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17362         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
17363         return tag_ptr(ret_conv, true);
17364 }
17365
17366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17367         void* e_ptr = untag_ptr(e);
17368         CHECK_ACCESS(e_ptr);
17369         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17370         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17371         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17372         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
17373         return tag_ptr(ret_conv, true);
17374 }
17375
17376 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17377         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
17378         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
17379         return ret_conv;
17380 }
17381
17382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17383         if (!ptr_is_owned(_res)) return;
17384         void* _res_ptr = untag_ptr(_res);
17385         CHECK_ACCESS(_res_ptr);
17386         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
17387         FREE(untag_ptr(_res));
17388         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
17389 }
17390
17391 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
17392         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17393         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
17394         return tag_ptr(ret_conv, true);
17395 }
17396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17397         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
17398         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
17399         return ret_conv;
17400 }
17401
17402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17403         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
17404         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17405         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
17406         return tag_ptr(ret_conv, true);
17407 }
17408
17409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17410         LDKCVec_RouteHintZ _res_constr;
17411         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17412         if (_res_constr.datalen > 0)
17413                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
17414         else
17415                 _res_constr.data = NULL;
17416         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17417         for (size_t l = 0; l < _res_constr.datalen; l++) {
17418                 int64_t _res_conv_11 = _res_vals[l];
17419                 LDKRouteHint _res_conv_11_conv;
17420                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
17421                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
17422                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
17423                 _res_constr.data[l] = _res_conv_11_conv;
17424         }
17425         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17426         CVec_RouteHintZ_free(_res_constr);
17427 }
17428
17429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17430         LDKCVec_u64Z _res_constr;
17431         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17432         if (_res_constr.datalen > 0)
17433                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17434         else
17435                 _res_constr.data = NULL;
17436         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17437         for (size_t g = 0; g < _res_constr.datalen; g++) {
17438                 int64_t _res_conv_6 = _res_vals[g];
17439                 _res_constr.data[g] = _res_conv_6;
17440         }
17441         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17442         CVec_u64Z_free(_res_constr);
17443 }
17444
17445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17446         LDKPaymentParameters o_conv;
17447         o_conv.inner = untag_ptr(o);
17448         o_conv.is_owned = ptr_is_owned(o);
17449         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17450         o_conv = PaymentParameters_clone(&o_conv);
17451         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17452         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
17453         return tag_ptr(ret_conv, true);
17454 }
17455
17456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17457         void* e_ptr = untag_ptr(e);
17458         CHECK_ACCESS(e_ptr);
17459         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17460         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17461         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17462         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
17463         return tag_ptr(ret_conv, true);
17464 }
17465
17466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17467         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
17468         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
17469         return ret_conv;
17470 }
17471
17472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17473         if (!ptr_is_owned(_res)) return;
17474         void* _res_ptr = untag_ptr(_res);
17475         CHECK_ACCESS(_res_ptr);
17476         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
17477         FREE(untag_ptr(_res));
17478         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
17479 }
17480
17481 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
17482         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17483         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
17484         return tag_ptr(ret_conv, true);
17485 }
17486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17487         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
17488         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
17489         return ret_conv;
17490 }
17491
17492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17493         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
17494         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17495         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
17496         return tag_ptr(ret_conv, true);
17497 }
17498
17499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17500         LDKCVec_RouteHintHopZ _res_constr;
17501         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17502         if (_res_constr.datalen > 0)
17503                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
17504         else
17505                 _res_constr.data = NULL;
17506         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17507         for (size_t o = 0; o < _res_constr.datalen; o++) {
17508                 int64_t _res_conv_14 = _res_vals[o];
17509                 LDKRouteHintHop _res_conv_14_conv;
17510                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
17511                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
17512                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17513                 _res_constr.data[o] = _res_conv_14_conv;
17514         }
17515         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17516         CVec_RouteHintHopZ_free(_res_constr);
17517 }
17518
17519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17520         LDKRouteHint o_conv;
17521         o_conv.inner = untag_ptr(o);
17522         o_conv.is_owned = ptr_is_owned(o);
17523         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17524         o_conv = RouteHint_clone(&o_conv);
17525         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17526         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
17527         return tag_ptr(ret_conv, true);
17528 }
17529
17530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17531         void* e_ptr = untag_ptr(e);
17532         CHECK_ACCESS(e_ptr);
17533         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17534         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17535         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17536         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
17537         return tag_ptr(ret_conv, true);
17538 }
17539
17540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17541         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
17542         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
17543         return ret_conv;
17544 }
17545
17546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17547         if (!ptr_is_owned(_res)) return;
17548         void* _res_ptr = untag_ptr(_res);
17549         CHECK_ACCESS(_res_ptr);
17550         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
17551         FREE(untag_ptr(_res));
17552         CResult_RouteHintDecodeErrorZ_free(_res_conv);
17553 }
17554
17555 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
17556         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17557         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
17558         return tag_ptr(ret_conv, true);
17559 }
17560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17561         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
17562         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
17563         return ret_conv;
17564 }
17565
17566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17567         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
17568         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17569         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
17570         return tag_ptr(ret_conv, true);
17571 }
17572
17573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17574         LDKRouteHintHop o_conv;
17575         o_conv.inner = untag_ptr(o);
17576         o_conv.is_owned = ptr_is_owned(o);
17577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17578         o_conv = RouteHintHop_clone(&o_conv);
17579         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17580         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
17581         return tag_ptr(ret_conv, true);
17582 }
17583
17584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17585         void* e_ptr = untag_ptr(e);
17586         CHECK_ACCESS(e_ptr);
17587         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17588         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17589         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17590         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
17591         return tag_ptr(ret_conv, true);
17592 }
17593
17594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17595         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
17596         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
17597         return ret_conv;
17598 }
17599
17600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17601         if (!ptr_is_owned(_res)) return;
17602         void* _res_ptr = untag_ptr(_res);
17603         CHECK_ACCESS(_res_ptr);
17604         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
17605         FREE(untag_ptr(_res));
17606         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
17607 }
17608
17609 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
17610         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17611         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
17612         return tag_ptr(ret_conv, true);
17613 }
17614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17615         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
17616         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
17617         return ret_conv;
17618 }
17619
17620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17621         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
17622         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17623         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
17624         return tag_ptr(ret_conv, true);
17625 }
17626
17627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17628         void* o_ptr = untag_ptr(o);
17629         CHECK_ACCESS(o_ptr);
17630         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
17631         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
17632         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17633         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
17634         return tag_ptr(ret_conv, true);
17635 }
17636
17637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17638         void* e_ptr = untag_ptr(e);
17639         CHECK_ACCESS(e_ptr);
17640         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17641         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17642         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17643         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
17644         return tag_ptr(ret_conv, true);
17645 }
17646
17647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17648         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
17649         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
17650         return ret_conv;
17651 }
17652
17653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17654         if (!ptr_is_owned(_res)) return;
17655         void* _res_ptr = untag_ptr(_res);
17656         CHECK_ACCESS(_res_ptr);
17657         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
17658         FREE(untag_ptr(_res));
17659         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
17660 }
17661
17662 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
17663         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17664         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
17665         return tag_ptr(ret_conv, true);
17666 }
17667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17668         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
17669         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
17670         return ret_conv;
17671 }
17672
17673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17674         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
17675         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17676         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
17677         return tag_ptr(ret_conv, true);
17678 }
17679
17680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17681         void* o_ptr = untag_ptr(o);
17682         CHECK_ACCESS(o_ptr);
17683         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
17684         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
17685         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17686         *ret_copy = COption_ClosureReasonZ_some(o_conv);
17687         int64_t ret_ref = tag_ptr(ret_copy, true);
17688         return ret_ref;
17689 }
17690
17691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
17692         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17693         *ret_copy = COption_ClosureReasonZ_none();
17694         int64_t ret_ref = tag_ptr(ret_copy, true);
17695         return ret_ref;
17696 }
17697
17698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17699         if (!ptr_is_owned(_res)) return;
17700         void* _res_ptr = untag_ptr(_res);
17701         CHECK_ACCESS(_res_ptr);
17702         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
17703         FREE(untag_ptr(_res));
17704         COption_ClosureReasonZ_free(_res_conv);
17705 }
17706
17707 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
17708         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17709         *ret_copy = COption_ClosureReasonZ_clone(arg);
17710         int64_t ret_ref = tag_ptr(ret_copy, true);
17711         return ret_ref;
17712 }
17713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17714         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
17715         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
17716         return ret_conv;
17717 }
17718
17719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17720         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
17721         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17722         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
17723         int64_t ret_ref = tag_ptr(ret_copy, true);
17724         return ret_ref;
17725 }
17726
17727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17728         void* o_ptr = untag_ptr(o);
17729         CHECK_ACCESS(o_ptr);
17730         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
17731         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
17732         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17733         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
17734         return tag_ptr(ret_conv, true);
17735 }
17736
17737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17738         void* e_ptr = untag_ptr(e);
17739         CHECK_ACCESS(e_ptr);
17740         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17741         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17742         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17743         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
17744         return tag_ptr(ret_conv, true);
17745 }
17746
17747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17748         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
17749         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
17750         return ret_conv;
17751 }
17752
17753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17754         if (!ptr_is_owned(_res)) return;
17755         void* _res_ptr = untag_ptr(_res);
17756         CHECK_ACCESS(_res_ptr);
17757         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
17758         FREE(untag_ptr(_res));
17759         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
17760 }
17761
17762 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
17763         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17764         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
17765         return tag_ptr(ret_conv, true);
17766 }
17767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17768         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
17769         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
17770         return ret_conv;
17771 }
17772
17773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17774         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
17775         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17776         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
17777         return tag_ptr(ret_conv, true);
17778 }
17779
17780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17781         void* o_ptr = untag_ptr(o);
17782         CHECK_ACCESS(o_ptr);
17783         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
17784         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
17785         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17786         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
17787         int64_t ret_ref = tag_ptr(ret_copy, true);
17788         return ret_ref;
17789 }
17790
17791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
17792         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17793         *ret_copy = COption_HTLCDestinationZ_none();
17794         int64_t ret_ref = tag_ptr(ret_copy, true);
17795         return ret_ref;
17796 }
17797
17798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17799         if (!ptr_is_owned(_res)) return;
17800         void* _res_ptr = untag_ptr(_res);
17801         CHECK_ACCESS(_res_ptr);
17802         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
17803         FREE(untag_ptr(_res));
17804         COption_HTLCDestinationZ_free(_res_conv);
17805 }
17806
17807 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
17808         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17809         *ret_copy = COption_HTLCDestinationZ_clone(arg);
17810         int64_t ret_ref = tag_ptr(ret_copy, true);
17811         return ret_ref;
17812 }
17813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17814         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
17815         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
17816         return ret_conv;
17817 }
17818
17819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17820         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
17821         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17822         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
17823         int64_t ret_ref = tag_ptr(ret_copy, true);
17824         return ret_ref;
17825 }
17826
17827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17828         void* o_ptr = untag_ptr(o);
17829         CHECK_ACCESS(o_ptr);
17830         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
17831         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
17832         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17833         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
17834         return tag_ptr(ret_conv, true);
17835 }
17836
17837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17838         void* e_ptr = untag_ptr(e);
17839         CHECK_ACCESS(e_ptr);
17840         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17841         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17842         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17843         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
17844         return tag_ptr(ret_conv, true);
17845 }
17846
17847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17848         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
17849         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
17850         return ret_conv;
17851 }
17852
17853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17854         if (!ptr_is_owned(_res)) return;
17855         void* _res_ptr = untag_ptr(_res);
17856         CHECK_ACCESS(_res_ptr);
17857         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
17858         FREE(untag_ptr(_res));
17859         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
17860 }
17861
17862 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
17863         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17864         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
17865         return tag_ptr(ret_conv, true);
17866 }
17867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17868         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
17869         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
17870         return ret_conv;
17871 }
17872
17873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17874         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
17875         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17876         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
17877         return tag_ptr(ret_conv, true);
17878 }
17879
17880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1some(JNIEnv *env, jclass clz, int8_tArray o) {
17881         LDKU128 o_ref;
17882         CHECK((*env)->GetArrayLength(env, o) == 16);
17883         (*env)->GetByteArrayRegion(env, o, 0, 16, o_ref.le_bytes);
17884         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17885         *ret_copy = COption_u128Z_some(o_ref);
17886         int64_t ret_ref = tag_ptr(ret_copy, true);
17887         return ret_ref;
17888 }
17889
17890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1none(JNIEnv *env, jclass clz) {
17891         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17892         *ret_copy = COption_u128Z_none();
17893         int64_t ret_ref = tag_ptr(ret_copy, true);
17894         return ret_ref;
17895 }
17896
17897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17898         if (!ptr_is_owned(_res)) return;
17899         void* _res_ptr = untag_ptr(_res);
17900         CHECK_ACCESS(_res_ptr);
17901         LDKCOption_u128Z _res_conv = *(LDKCOption_u128Z*)(_res_ptr);
17902         FREE(untag_ptr(_res));
17903         COption_u128Z_free(_res_conv);
17904 }
17905
17906 static inline uint64_t COption_u128Z_clone_ptr(LDKCOption_u128Z *NONNULL_PTR arg) {
17907         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17908         *ret_copy = COption_u128Z_clone(arg);
17909         int64_t ret_ref = tag_ptr(ret_copy, true);
17910         return ret_ref;
17911 }
17912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17913         LDKCOption_u128Z* arg_conv = (LDKCOption_u128Z*)untag_ptr(arg);
17914         int64_t ret_conv = COption_u128Z_clone_ptr(arg_conv);
17915         return ret_conv;
17916 }
17917
17918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17919         LDKCOption_u128Z* orig_conv = (LDKCOption_u128Z*)untag_ptr(orig);
17920         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17921         *ret_copy = COption_u128Z_clone(orig_conv);
17922         int64_t ret_ref = tag_ptr(ret_copy, true);
17923         return ret_ref;
17924 }
17925
17926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17927         void* o_ptr = untag_ptr(o);
17928         CHECK_ACCESS(o_ptr);
17929         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
17930         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
17931         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17932         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
17933         int64_t ret_ref = tag_ptr(ret_copy, true);
17934         return ret_ref;
17935 }
17936
17937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
17938         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17939         *ret_copy = COption_NetworkUpdateZ_none();
17940         int64_t ret_ref = tag_ptr(ret_copy, true);
17941         return ret_ref;
17942 }
17943
17944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17945         if (!ptr_is_owned(_res)) return;
17946         void* _res_ptr = untag_ptr(_res);
17947         CHECK_ACCESS(_res_ptr);
17948         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
17949         FREE(untag_ptr(_res));
17950         COption_NetworkUpdateZ_free(_res_conv);
17951 }
17952
17953 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
17954         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17955         *ret_copy = COption_NetworkUpdateZ_clone(arg);
17956         int64_t ret_ref = tag_ptr(ret_copy, true);
17957         return ret_ref;
17958 }
17959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17960         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
17961         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
17962         return ret_conv;
17963 }
17964
17965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17966         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
17967         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17968         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
17969         int64_t ret_ref = tag_ptr(ret_copy, true);
17970         return ret_ref;
17971 }
17972
17973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17974         LDKCVec_SpendableOutputDescriptorZ _res_constr;
17975         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17976         if (_res_constr.datalen > 0)
17977                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
17978         else
17979                 _res_constr.data = NULL;
17980         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17981         for (size_t b = 0; b < _res_constr.datalen; b++) {
17982                 int64_t _res_conv_27 = _res_vals[b];
17983                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
17984                 CHECK_ACCESS(_res_conv_27_ptr);
17985                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
17986                 FREE(untag_ptr(_res_conv_27));
17987                 _res_constr.data[b] = _res_conv_27_conv;
17988         }
17989         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17990         CVec_SpendableOutputDescriptorZ_free(_res_constr);
17991 }
17992
17993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17994         void* o_ptr = untag_ptr(o);
17995         CHECK_ACCESS(o_ptr);
17996         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
17997         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
17998         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17999         *ret_copy = COption_EventZ_some(o_conv);
18000         int64_t ret_ref = tag_ptr(ret_copy, true);
18001         return ret_ref;
18002 }
18003
18004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
18005         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18006         *ret_copy = COption_EventZ_none();
18007         int64_t ret_ref = tag_ptr(ret_copy, true);
18008         return ret_ref;
18009 }
18010
18011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18012         if (!ptr_is_owned(_res)) return;
18013         void* _res_ptr = untag_ptr(_res);
18014         CHECK_ACCESS(_res_ptr);
18015         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
18016         FREE(untag_ptr(_res));
18017         COption_EventZ_free(_res_conv);
18018 }
18019
18020 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
18021         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18022         *ret_copy = COption_EventZ_clone(arg);
18023         int64_t ret_ref = tag_ptr(ret_copy, true);
18024         return ret_ref;
18025 }
18026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18027         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
18028         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
18029         return ret_conv;
18030 }
18031
18032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18033         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
18034         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18035         *ret_copy = COption_EventZ_clone(orig_conv);
18036         int64_t ret_ref = tag_ptr(ret_copy, true);
18037         return ret_ref;
18038 }
18039
18040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18041         void* o_ptr = untag_ptr(o);
18042         CHECK_ACCESS(o_ptr);
18043         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
18044         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
18045         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18046         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
18047         return tag_ptr(ret_conv, true);
18048 }
18049
18050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18051         void* e_ptr = untag_ptr(e);
18052         CHECK_ACCESS(e_ptr);
18053         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18054         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18055         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18056         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
18057         return tag_ptr(ret_conv, true);
18058 }
18059
18060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18061         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
18062         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
18063         return ret_conv;
18064 }
18065
18066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18067         if (!ptr_is_owned(_res)) return;
18068         void* _res_ptr = untag_ptr(_res);
18069         CHECK_ACCESS(_res_ptr);
18070         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
18071         FREE(untag_ptr(_res));
18072         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
18073 }
18074
18075 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
18076         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18077         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
18078         return tag_ptr(ret_conv, true);
18079 }
18080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18081         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
18082         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
18083         return ret_conv;
18084 }
18085
18086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18087         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
18088         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18089         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
18090         return tag_ptr(ret_conv, true);
18091 }
18092
18093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18094         LDKCVec_MessageSendEventZ _res_constr;
18095         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18096         if (_res_constr.datalen > 0)
18097                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
18098         else
18099                 _res_constr.data = NULL;
18100         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18101         for (size_t s = 0; s < _res_constr.datalen; s++) {
18102                 int64_t _res_conv_18 = _res_vals[s];
18103                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
18104                 CHECK_ACCESS(_res_conv_18_ptr);
18105                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
18106                 FREE(untag_ptr(_res_conv_18));
18107                 _res_constr.data[s] = _res_conv_18_conv;
18108         }
18109         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18110         CVec_MessageSendEventZ_free(_res_constr);
18111 }
18112
18113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18114         void* o_ptr = untag_ptr(o);
18115         CHECK_ACCESS(o_ptr);
18116         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
18117         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
18118         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18119         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
18120         return tag_ptr(ret_conv, true);
18121 }
18122
18123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18124         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
18125         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18126         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
18127         return tag_ptr(ret_conv, true);
18128 }
18129
18130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18131         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(o);
18132         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
18133         return ret_conv;
18134 }
18135
18136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18137         if (!ptr_is_owned(_res)) return;
18138         void* _res_ptr = untag_ptr(_res);
18139         CHECK_ACCESS(_res_ptr);
18140         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
18141         FREE(untag_ptr(_res));
18142         CResult_TxOutAccessErrorZ_free(_res_conv);
18143 }
18144
18145 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
18146         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18147         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
18148         return tag_ptr(ret_conv, true);
18149 }
18150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18151         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(arg);
18152         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
18153         return ret_conv;
18154 }
18155
18156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18157         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(orig);
18158         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18159         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
18160         return tag_ptr(ret_conv, true);
18161 }
18162
18163 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
18164         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18165         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
18166         return tag_ptr(ret_conv, true);
18167 }
18168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18169         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
18170         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
18171         return ret_conv;
18172 }
18173
18174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18175         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
18176         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18177         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
18178         return tag_ptr(ret_conv, true);
18179 }
18180
18181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
18182         LDKTransaction b_ref;
18183         b_ref.datalen = (*env)->GetArrayLength(env, b);
18184         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
18185         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
18186         b_ref.data_is_owned = true;
18187         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18188         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
18189         return tag_ptr(ret_conv, true);
18190 }
18191
18192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18193         if (!ptr_is_owned(_res)) return;
18194         void* _res_ptr = untag_ptr(_res);
18195         CHECK_ACCESS(_res_ptr);
18196         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
18197         FREE(untag_ptr(_res));
18198         C2Tuple_usizeTransactionZ_free(_res_conv);
18199 }
18200
18201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18202         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
18203         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18204         if (_res_constr.datalen > 0)
18205                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18206         else
18207                 _res_constr.data = NULL;
18208         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18209         for (size_t c = 0; c < _res_constr.datalen; c++) {
18210                 int64_t _res_conv_28 = _res_vals[c];
18211                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
18212                 CHECK_ACCESS(_res_conv_28_ptr);
18213                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
18214                 FREE(untag_ptr(_res_conv_28));
18215                 _res_constr.data[c] = _res_conv_28_conv;
18216         }
18217         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18218         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
18219 }
18220
18221 static inline uint64_t C2Tuple_TxidBlockHashZ_clone_ptr(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR arg) {
18222         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18223         *ret_conv = C2Tuple_TxidBlockHashZ_clone(arg);
18224         return tag_ptr(ret_conv, true);
18225 }
18226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18227         LDKC2Tuple_TxidBlockHashZ* arg_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(arg);
18228         int64_t ret_conv = C2Tuple_TxidBlockHashZ_clone_ptr(arg_conv);
18229         return ret_conv;
18230 }
18231
18232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18233         LDKC2Tuple_TxidBlockHashZ* orig_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(orig);
18234         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18235         *ret_conv = C2Tuple_TxidBlockHashZ_clone(orig_conv);
18236         return tag_ptr(ret_conv, true);
18237 }
18238
18239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18240         LDKThirtyTwoBytes a_ref;
18241         CHECK((*env)->GetArrayLength(env, a) == 32);
18242         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18243         LDKThirtyTwoBytes b_ref;
18244         CHECK((*env)->GetArrayLength(env, b) == 32);
18245         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18246         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18247         *ret_conv = C2Tuple_TxidBlockHashZ_new(a_ref, b_ref);
18248         return tag_ptr(ret_conv, true);
18249 }
18250
18251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18252         if (!ptr_is_owned(_res)) return;
18253         void* _res_ptr = untag_ptr(_res);
18254         CHECK_ACCESS(_res_ptr);
18255         LDKC2Tuple_TxidBlockHashZ _res_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_ptr);
18256         FREE(untag_ptr(_res));
18257         C2Tuple_TxidBlockHashZ_free(_res_conv);
18258 }
18259
18260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidBlockHashZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18261         LDKCVec_C2Tuple_TxidBlockHashZZ _res_constr;
18262         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18263         if (_res_constr.datalen > 0)
18264                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
18265         else
18266                 _res_constr.data = NULL;
18267         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18268         for (size_t z = 0; z < _res_constr.datalen; z++) {
18269                 int64_t _res_conv_25 = _res_vals[z];
18270                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
18271                 CHECK_ACCESS(_res_conv_25_ptr);
18272                 LDKC2Tuple_TxidBlockHashZ _res_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_conv_25_ptr);
18273                 FREE(untag_ptr(_res_conv_25));
18274                 _res_constr.data[z] = _res_conv_25_conv;
18275         }
18276         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18277         CVec_C2Tuple_TxidBlockHashZZ_free(_res_constr);
18278 }
18279
18280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18281         LDKCVec_MonitorEventZ _res_constr;
18282         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18283         if (_res_constr.datalen > 0)
18284                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18285         else
18286                 _res_constr.data = NULL;
18287         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18288         for (size_t o = 0; o < _res_constr.datalen; o++) {
18289                 int64_t _res_conv_14 = _res_vals[o];
18290                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
18291                 CHECK_ACCESS(_res_conv_14_ptr);
18292                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
18293                 FREE(untag_ptr(_res_conv_14));
18294                 _res_constr.data[o] = _res_conv_14_conv;
18295         }
18296         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18297         CVec_MonitorEventZ_free(_res_constr);
18298 }
18299
18300 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
18301         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18302         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
18303         return tag_ptr(ret_conv, true);
18304 }
18305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18306         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
18307         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
18308         return ret_conv;
18309 }
18310
18311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18312         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
18313         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18314         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
18315         return tag_ptr(ret_conv, true);
18316 }
18317
18318 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) {
18319         LDKOutPoint a_conv;
18320         a_conv.inner = untag_ptr(a);
18321         a_conv.is_owned = ptr_is_owned(a);
18322         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18323         a_conv = OutPoint_clone(&a_conv);
18324         LDKCVec_MonitorEventZ b_constr;
18325         b_constr.datalen = (*env)->GetArrayLength(env, b);
18326         if (b_constr.datalen > 0)
18327                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18328         else
18329                 b_constr.data = NULL;
18330         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
18331         for (size_t o = 0; o < b_constr.datalen; o++) {
18332                 int64_t b_conv_14 = b_vals[o];
18333                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
18334                 CHECK_ACCESS(b_conv_14_ptr);
18335                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
18336                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
18337                 b_constr.data[o] = b_conv_14_conv;
18338         }
18339         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
18340         LDKPublicKey c_ref;
18341         CHECK((*env)->GetArrayLength(env, c) == 33);
18342         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
18343         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18344         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
18345         return tag_ptr(ret_conv, true);
18346 }
18347
18348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18349         if (!ptr_is_owned(_res)) return;
18350         void* _res_ptr = untag_ptr(_res);
18351         CHECK_ACCESS(_res_ptr);
18352         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
18353         FREE(untag_ptr(_res));
18354         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
18355 }
18356
18357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18358         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
18359         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18360         if (_res_constr.datalen > 0)
18361                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
18362         else
18363                 _res_constr.data = NULL;
18364         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18365         for (size_t x = 0; x < _res_constr.datalen; x++) {
18366                 int64_t _res_conv_49 = _res_vals[x];
18367                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18368                 CHECK_ACCESS(_res_conv_49_ptr);
18369                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
18370                 FREE(untag_ptr(_res_conv_49));
18371                 _res_constr.data[x] = _res_conv_49_conv;
18372         }
18373         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18374         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
18375 }
18376
18377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18378         LDKFixedPenaltyScorer o_conv;
18379         o_conv.inner = untag_ptr(o);
18380         o_conv.is_owned = ptr_is_owned(o);
18381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18382         o_conv = FixedPenaltyScorer_clone(&o_conv);
18383         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18384         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
18385         return tag_ptr(ret_conv, true);
18386 }
18387
18388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18389         void* e_ptr = untag_ptr(e);
18390         CHECK_ACCESS(e_ptr);
18391         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18392         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18393         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18394         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
18395         return tag_ptr(ret_conv, true);
18396 }
18397
18398 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18399         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
18400         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
18401         return ret_conv;
18402 }
18403
18404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18405         if (!ptr_is_owned(_res)) return;
18406         void* _res_ptr = untag_ptr(_res);
18407         CHECK_ACCESS(_res_ptr);
18408         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
18409         FREE(untag_ptr(_res));
18410         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
18411 }
18412
18413 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
18414         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18415         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
18416         return tag_ptr(ret_conv, true);
18417 }
18418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18419         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
18420         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
18421         return ret_conv;
18422 }
18423
18424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18425         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
18426         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18427         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
18428         return tag_ptr(ret_conv, true);
18429 }
18430
18431 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
18432         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18433         *ret_conv = C2Tuple_u64u64Z_clone(arg);
18434         return tag_ptr(ret_conv, true);
18435 }
18436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18437         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
18438         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
18439         return ret_conv;
18440 }
18441
18442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18443         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
18444         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18445         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
18446         return tag_ptr(ret_conv, true);
18447 }
18448
18449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18450         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18451         *ret_conv = C2Tuple_u64u64Z_new(a, b);
18452         return tag_ptr(ret_conv, true);
18453 }
18454
18455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18456         if (!ptr_is_owned(_res)) return;
18457         void* _res_ptr = untag_ptr(_res);
18458         CHECK_ACCESS(_res_ptr);
18459         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
18460         FREE(untag_ptr(_res));
18461         C2Tuple_u64u64Z_free(_res_conv);
18462 }
18463
18464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18465         void* o_ptr = untag_ptr(o);
18466         CHECK_ACCESS(o_ptr);
18467         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
18468         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
18469         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18470         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
18471         int64_t ret_ref = tag_ptr(ret_copy, true);
18472         return ret_ref;
18473 }
18474
18475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
18476         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18477         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
18478         int64_t ret_ref = tag_ptr(ret_copy, true);
18479         return ret_ref;
18480 }
18481
18482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18483         if (!ptr_is_owned(_res)) return;
18484         void* _res_ptr = untag_ptr(_res);
18485         CHECK_ACCESS(_res_ptr);
18486         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
18487         FREE(untag_ptr(_res));
18488         COption_C2Tuple_u64u64ZZ_free(_res_conv);
18489 }
18490
18491 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
18492         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18493         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
18494         int64_t ret_ref = tag_ptr(ret_copy, true);
18495         return ret_ref;
18496 }
18497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18498         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
18499         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
18500         return ret_conv;
18501 }
18502
18503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18504         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
18505         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18506         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
18507         int64_t ret_ref = tag_ptr(ret_copy, true);
18508         return ret_ref;
18509 }
18510
18511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18512         LDKCVec_NodeIdZ _res_constr;
18513         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18514         if (_res_constr.datalen > 0)
18515                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
18516         else
18517                 _res_constr.data = NULL;
18518         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18519         for (size_t i = 0; i < _res_constr.datalen; i++) {
18520                 int64_t _res_conv_8 = _res_vals[i];
18521                 LDKNodeId _res_conv_8_conv;
18522                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
18523                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
18524                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
18525                 _res_constr.data[i] = _res_conv_8_conv;
18526         }
18527         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18528         CVec_NodeIdZ_free(_res_constr);
18529 }
18530
18531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18532         LDKProbabilisticScorer o_conv;
18533         o_conv.inner = untag_ptr(o);
18534         o_conv.is_owned = ptr_is_owned(o);
18535         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18536         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
18537         
18538         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18539         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18540         return tag_ptr(ret_conv, true);
18541 }
18542
18543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18544         void* e_ptr = untag_ptr(e);
18545         CHECK_ACCESS(e_ptr);
18546         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18547         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18548         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18549         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18550         return tag_ptr(ret_conv, true);
18551 }
18552
18553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18554         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18555         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18556         return ret_conv;
18557 }
18558
18559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18560         if (!ptr_is_owned(_res)) return;
18561         void* _res_ptr = untag_ptr(_res);
18562         CHECK_ACCESS(_res_ptr);
18563         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18564         FREE(untag_ptr(_res));
18565         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18566 }
18567
18568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18569         LDKInitFeatures o_conv;
18570         o_conv.inner = untag_ptr(o);
18571         o_conv.is_owned = ptr_is_owned(o);
18572         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18573         o_conv = InitFeatures_clone(&o_conv);
18574         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18575         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18576         return tag_ptr(ret_conv, true);
18577 }
18578
18579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18580         void* e_ptr = untag_ptr(e);
18581         CHECK_ACCESS(e_ptr);
18582         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18583         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18584         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18585         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18586         return tag_ptr(ret_conv, true);
18587 }
18588
18589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18590         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18591         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18592         return ret_conv;
18593 }
18594
18595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18596         if (!ptr_is_owned(_res)) return;
18597         void* _res_ptr = untag_ptr(_res);
18598         CHECK_ACCESS(_res_ptr);
18599         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18600         FREE(untag_ptr(_res));
18601         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18602 }
18603
18604 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18605         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18606         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18607         return tag_ptr(ret_conv, true);
18608 }
18609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18610         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18611         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18612         return ret_conv;
18613 }
18614
18615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18616         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
18617         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18618         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
18619         return tag_ptr(ret_conv, true);
18620 }
18621
18622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18623         LDKChannelFeatures o_conv;
18624         o_conv.inner = untag_ptr(o);
18625         o_conv.is_owned = ptr_is_owned(o);
18626         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18627         o_conv = ChannelFeatures_clone(&o_conv);
18628         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18629         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
18630         return tag_ptr(ret_conv, true);
18631 }
18632
18633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18634         void* e_ptr = untag_ptr(e);
18635         CHECK_ACCESS(e_ptr);
18636         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18637         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18638         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18639         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
18640         return tag_ptr(ret_conv, true);
18641 }
18642
18643 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18644         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
18645         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
18646         return ret_conv;
18647 }
18648
18649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18650         if (!ptr_is_owned(_res)) return;
18651         void* _res_ptr = untag_ptr(_res);
18652         CHECK_ACCESS(_res_ptr);
18653         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
18654         FREE(untag_ptr(_res));
18655         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
18656 }
18657
18658 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18659         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18660         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
18661         return tag_ptr(ret_conv, true);
18662 }
18663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18664         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
18665         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18666         return ret_conv;
18667 }
18668
18669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18670         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
18671         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18672         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
18673         return tag_ptr(ret_conv, true);
18674 }
18675
18676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18677         LDKNodeFeatures o_conv;
18678         o_conv.inner = untag_ptr(o);
18679         o_conv.is_owned = ptr_is_owned(o);
18680         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18681         o_conv = NodeFeatures_clone(&o_conv);
18682         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18683         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
18684         return tag_ptr(ret_conv, true);
18685 }
18686
18687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18688         void* e_ptr = untag_ptr(e);
18689         CHECK_ACCESS(e_ptr);
18690         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18691         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18692         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18693         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
18694         return tag_ptr(ret_conv, true);
18695 }
18696
18697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18698         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
18699         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
18700         return ret_conv;
18701 }
18702
18703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18704         if (!ptr_is_owned(_res)) return;
18705         void* _res_ptr = untag_ptr(_res);
18706         CHECK_ACCESS(_res_ptr);
18707         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
18708         FREE(untag_ptr(_res));
18709         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
18710 }
18711
18712 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18713         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18714         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
18715         return tag_ptr(ret_conv, true);
18716 }
18717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18718         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
18719         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18720         return ret_conv;
18721 }
18722
18723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18724         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
18725         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18726         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
18727         return tag_ptr(ret_conv, true);
18728 }
18729
18730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18731         LDKInvoiceFeatures o_conv;
18732         o_conv.inner = untag_ptr(o);
18733         o_conv.is_owned = ptr_is_owned(o);
18734         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18735         o_conv = InvoiceFeatures_clone(&o_conv);
18736         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18737         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
18738         return tag_ptr(ret_conv, true);
18739 }
18740
18741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18742         void* e_ptr = untag_ptr(e);
18743         CHECK_ACCESS(e_ptr);
18744         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18745         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18746         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18747         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
18748         return tag_ptr(ret_conv, true);
18749 }
18750
18751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18752         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
18753         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
18754         return ret_conv;
18755 }
18756
18757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18758         if (!ptr_is_owned(_res)) return;
18759         void* _res_ptr = untag_ptr(_res);
18760         CHECK_ACCESS(_res_ptr);
18761         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
18762         FREE(untag_ptr(_res));
18763         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
18764 }
18765
18766 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18767         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18768         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
18769         return tag_ptr(ret_conv, true);
18770 }
18771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18772         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18773         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18774         return ret_conv;
18775 }
18776
18777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18778         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18779         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18780         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18781         return tag_ptr(ret_conv, true);
18782 }
18783
18784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18785         LDKChannelTypeFeatures o_conv;
18786         o_conv.inner = untag_ptr(o);
18787         o_conv.is_owned = ptr_is_owned(o);
18788         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18789         o_conv = ChannelTypeFeatures_clone(&o_conv);
18790         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18791         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
18792         return tag_ptr(ret_conv, true);
18793 }
18794
18795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18796         void* e_ptr = untag_ptr(e);
18797         CHECK_ACCESS(e_ptr);
18798         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18799         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18800         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18801         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
18802         return tag_ptr(ret_conv, true);
18803 }
18804
18805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18806         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
18807         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
18808         return ret_conv;
18809 }
18810
18811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18812         if (!ptr_is_owned(_res)) return;
18813         void* _res_ptr = untag_ptr(_res);
18814         CHECK_ACCESS(_res_ptr);
18815         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
18816         FREE(untag_ptr(_res));
18817         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
18818 }
18819
18820 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18821         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18822         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
18823         return tag_ptr(ret_conv, true);
18824 }
18825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18826         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
18827         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18828         return ret_conv;
18829 }
18830
18831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18832         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
18833         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18834         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
18835         return tag_ptr(ret_conv, true);
18836 }
18837
18838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18839         LDKOfferFeatures o_conv;
18840         o_conv.inner = untag_ptr(o);
18841         o_conv.is_owned = ptr_is_owned(o);
18842         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18843         o_conv = OfferFeatures_clone(&o_conv);
18844         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18845         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_ok(o_conv);
18846         return tag_ptr(ret_conv, true);
18847 }
18848
18849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18850         void* e_ptr = untag_ptr(e);
18851         CHECK_ACCESS(e_ptr);
18852         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18853         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18854         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18855         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_err(e_conv);
18856         return tag_ptr(ret_conv, true);
18857 }
18858
18859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18860         LDKCResult_OfferFeaturesDecodeErrorZ* o_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(o);
18861         jboolean ret_conv = CResult_OfferFeaturesDecodeErrorZ_is_ok(o_conv);
18862         return ret_conv;
18863 }
18864
18865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18866         if (!ptr_is_owned(_res)) return;
18867         void* _res_ptr = untag_ptr(_res);
18868         CHECK_ACCESS(_res_ptr);
18869         LDKCResult_OfferFeaturesDecodeErrorZ _res_conv = *(LDKCResult_OfferFeaturesDecodeErrorZ*)(_res_ptr);
18870         FREE(untag_ptr(_res));
18871         CResult_OfferFeaturesDecodeErrorZ_free(_res_conv);
18872 }
18873
18874 static inline uint64_t CResult_OfferFeaturesDecodeErrorZ_clone_ptr(LDKCResult_OfferFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18875         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18876         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_clone(arg);
18877         return tag_ptr(ret_conv, true);
18878 }
18879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18880         LDKCResult_OfferFeaturesDecodeErrorZ* arg_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(arg);
18881         int64_t ret_conv = CResult_OfferFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18882         return ret_conv;
18883 }
18884
18885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18886         LDKCResult_OfferFeaturesDecodeErrorZ* orig_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(orig);
18887         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18888         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_clone(orig_conv);
18889         return tag_ptr(ret_conv, true);
18890 }
18891
18892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18893         LDKInvoiceRequestFeatures o_conv;
18894         o_conv.inner = untag_ptr(o);
18895         o_conv.is_owned = ptr_is_owned(o);
18896         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18897         o_conv = InvoiceRequestFeatures_clone(&o_conv);
18898         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18899         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_ok(o_conv);
18900         return tag_ptr(ret_conv, true);
18901 }
18902
18903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18904         void* e_ptr = untag_ptr(e);
18905         CHECK_ACCESS(e_ptr);
18906         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18907         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18908         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18909         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_err(e_conv);
18910         return tag_ptr(ret_conv, true);
18911 }
18912
18913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18914         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(o);
18915         jboolean ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_is_ok(o_conv);
18916         return ret_conv;
18917 }
18918
18919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18920         if (!ptr_is_owned(_res)) return;
18921         void* _res_ptr = untag_ptr(_res);
18922         CHECK_ACCESS(_res_ptr);
18923         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)(_res_ptr);
18924         FREE(untag_ptr(_res));
18925         CResult_InvoiceRequestFeaturesDecodeErrorZ_free(_res_conv);
18926 }
18927
18928 static inline uint64_t CResult_InvoiceRequestFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18929         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18930         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_clone(arg);
18931         return tag_ptr(ret_conv, true);
18932 }
18933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18934         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(arg);
18935         int64_t ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18936         return ret_conv;
18937 }
18938
18939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18940         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(orig);
18941         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18942         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_clone(orig_conv);
18943         return tag_ptr(ret_conv, true);
18944 }
18945
18946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18947         LDKNodeId o_conv;
18948         o_conv.inner = untag_ptr(o);
18949         o_conv.is_owned = ptr_is_owned(o);
18950         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18951         o_conv = NodeId_clone(&o_conv);
18952         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18953         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
18954         return tag_ptr(ret_conv, true);
18955 }
18956
18957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18958         void* e_ptr = untag_ptr(e);
18959         CHECK_ACCESS(e_ptr);
18960         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18961         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18962         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18963         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
18964         return tag_ptr(ret_conv, true);
18965 }
18966
18967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18968         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
18969         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
18970         return ret_conv;
18971 }
18972
18973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18974         if (!ptr_is_owned(_res)) return;
18975         void* _res_ptr = untag_ptr(_res);
18976         CHECK_ACCESS(_res_ptr);
18977         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
18978         FREE(untag_ptr(_res));
18979         CResult_NodeIdDecodeErrorZ_free(_res_conv);
18980 }
18981
18982 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
18983         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18984         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
18985         return tag_ptr(ret_conv, true);
18986 }
18987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18988         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
18989         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
18990         return ret_conv;
18991 }
18992
18993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18994         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
18995         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18996         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
18997         return tag_ptr(ret_conv, true);
18998 }
18999
19000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19001         void* o_ptr = untag_ptr(o);
19002         CHECK_ACCESS(o_ptr);
19003         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19004         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
19005         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19006         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19007         return tag_ptr(ret_conv, true);
19008 }
19009
19010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19011         void* e_ptr = untag_ptr(e);
19012         CHECK_ACCESS(e_ptr);
19013         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19014         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19015         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19016         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19017         return tag_ptr(ret_conv, true);
19018 }
19019
19020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19021         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
19022         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19023         return ret_conv;
19024 }
19025
19026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19027         if (!ptr_is_owned(_res)) return;
19028         void* _res_ptr = untag_ptr(_res);
19029         CHECK_ACCESS(_res_ptr);
19030         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
19031         FREE(untag_ptr(_res));
19032         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
19033 }
19034
19035 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
19036         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19037         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
19038         return tag_ptr(ret_conv, true);
19039 }
19040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19041         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
19042         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
19043         return ret_conv;
19044 }
19045
19046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19047         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
19048         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19049         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
19050         return tag_ptr(ret_conv, true);
19051 }
19052
19053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19054         void* o_ptr = untag_ptr(o);
19055         CHECK_ACCESS(o_ptr);
19056         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
19057         if (o_conv.free == LDKAccess_JCalls_free) {
19058                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19059                 LDKAccess_JCalls_cloned(&o_conv);
19060         }
19061         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
19062         *ret_copy = COption_AccessZ_some(o_conv);
19063         int64_t ret_ref = tag_ptr(ret_copy, true);
19064         return ret_ref;
19065 }
19066
19067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
19068         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
19069         *ret_copy = COption_AccessZ_none();
19070         int64_t ret_ref = tag_ptr(ret_copy, true);
19071         return ret_ref;
19072 }
19073
19074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19075         if (!ptr_is_owned(_res)) return;
19076         void* _res_ptr = untag_ptr(_res);
19077         CHECK_ACCESS(_res_ptr);
19078         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
19079         FREE(untag_ptr(_res));
19080         COption_AccessZ_free(_res_conv);
19081 }
19082
19083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19084         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19085         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19086         return tag_ptr(ret_conv, true);
19087 }
19088
19089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19090         LDKLightningError e_conv;
19091         e_conv.inner = untag_ptr(e);
19092         e_conv.is_owned = ptr_is_owned(e);
19093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19094         e_conv = LightningError_clone(&e_conv);
19095         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19096         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19097         return tag_ptr(ret_conv, true);
19098 }
19099
19100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19101         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
19102         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
19103         return ret_conv;
19104 }
19105
19106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19107         if (!ptr_is_owned(_res)) return;
19108         void* _res_ptr = untag_ptr(_res);
19109         CHECK_ACCESS(_res_ptr);
19110         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19111         FREE(untag_ptr(_res));
19112         CResult_boolLightningErrorZ_free(_res_conv);
19113 }
19114
19115 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19116         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19117         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19118         return tag_ptr(ret_conv, true);
19119 }
19120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19121         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
19122         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19123         return ret_conv;
19124 }
19125
19126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19127         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
19128         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19129         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19130         return tag_ptr(ret_conv, true);
19131 }
19132
19133 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19134         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19135         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19136         return tag_ptr(ret_conv, true);
19137 }
19138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19139         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
19140         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19141         return ret_conv;
19142 }
19143
19144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19145         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
19146         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19147         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19148         return tag_ptr(ret_conv, true);
19149 }
19150
19151 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) {
19152         LDKChannelAnnouncement a_conv;
19153         a_conv.inner = untag_ptr(a);
19154         a_conv.is_owned = ptr_is_owned(a);
19155         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19156         a_conv = ChannelAnnouncement_clone(&a_conv);
19157         LDKChannelUpdate b_conv;
19158         b_conv.inner = untag_ptr(b);
19159         b_conv.is_owned = ptr_is_owned(b);
19160         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19161         b_conv = ChannelUpdate_clone(&b_conv);
19162         LDKChannelUpdate c_conv;
19163         c_conv.inner = untag_ptr(c);
19164         c_conv.is_owned = ptr_is_owned(c);
19165         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19166         c_conv = ChannelUpdate_clone(&c_conv);
19167         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19168         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19169         return tag_ptr(ret_conv, true);
19170 }
19171
19172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19173         if (!ptr_is_owned(_res)) return;
19174         void* _res_ptr = untag_ptr(_res);
19175         CHECK_ACCESS(_res_ptr);
19176         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19177         FREE(untag_ptr(_res));
19178         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19179 }
19180
19181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19182         void* o_ptr = untag_ptr(o);
19183         CHECK_ACCESS(o_ptr);
19184         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
19185         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
19186         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19187         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
19188         int64_t ret_ref = tag_ptr(ret_copy, true);
19189         return ret_ref;
19190 }
19191
19192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
19193         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19194         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
19195         int64_t ret_ref = tag_ptr(ret_copy, true);
19196         return ret_ref;
19197 }
19198
19199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19200         if (!ptr_is_owned(_res)) return;
19201         void* _res_ptr = untag_ptr(_res);
19202         CHECK_ACCESS(_res_ptr);
19203         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
19204         FREE(untag_ptr(_res));
19205         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
19206 }
19207
19208 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
19209         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19210         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
19211         int64_t ret_ref = tag_ptr(ret_copy, true);
19212         return ret_ref;
19213 }
19214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19215         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
19216         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
19217         return ret_conv;
19218 }
19219
19220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19221         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
19222         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19223         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
19224         int64_t ret_ref = tag_ptr(ret_copy, true);
19225         return ret_ref;
19226 }
19227
19228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19229         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19230         *ret_conv = CResult_NoneLightningErrorZ_ok();
19231         return tag_ptr(ret_conv, true);
19232 }
19233
19234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19235         LDKLightningError e_conv;
19236         e_conv.inner = untag_ptr(e);
19237         e_conv.is_owned = ptr_is_owned(e);
19238         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19239         e_conv = LightningError_clone(&e_conv);
19240         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19241         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19242         return tag_ptr(ret_conv, true);
19243 }
19244
19245 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19246         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
19247         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
19248         return ret_conv;
19249 }
19250
19251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19252         if (!ptr_is_owned(_res)) return;
19253         void* _res_ptr = untag_ptr(_res);
19254         CHECK_ACCESS(_res_ptr);
19255         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19256         FREE(untag_ptr(_res));
19257         CResult_NoneLightningErrorZ_free(_res_conv);
19258 }
19259
19260 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19261         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19262         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19263         return tag_ptr(ret_conv, true);
19264 }
19265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19266         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
19267         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19268         return ret_conv;
19269 }
19270
19271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19272         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
19273         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19274         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19275         return tag_ptr(ret_conv, true);
19276 }
19277
19278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19279         LDKChannelUpdateInfo o_conv;
19280         o_conv.inner = untag_ptr(o);
19281         o_conv.is_owned = ptr_is_owned(o);
19282         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19283         o_conv = ChannelUpdateInfo_clone(&o_conv);
19284         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19285         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
19286         return tag_ptr(ret_conv, true);
19287 }
19288
19289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19290         void* e_ptr = untag_ptr(e);
19291         CHECK_ACCESS(e_ptr);
19292         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19293         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19294         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19295         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
19296         return tag_ptr(ret_conv, true);
19297 }
19298
19299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19300         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
19301         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
19302         return ret_conv;
19303 }
19304
19305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19306         if (!ptr_is_owned(_res)) return;
19307         void* _res_ptr = untag_ptr(_res);
19308         CHECK_ACCESS(_res_ptr);
19309         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
19310         FREE(untag_ptr(_res));
19311         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
19312 }
19313
19314 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
19315         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19316         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
19317         return tag_ptr(ret_conv, true);
19318 }
19319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19320         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
19321         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
19322         return ret_conv;
19323 }
19324
19325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19326         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
19327         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19328         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
19329         return tag_ptr(ret_conv, true);
19330 }
19331
19332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19333         LDKChannelInfo o_conv;
19334         o_conv.inner = untag_ptr(o);
19335         o_conv.is_owned = ptr_is_owned(o);
19336         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19337         o_conv = ChannelInfo_clone(&o_conv);
19338         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19339         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
19340         return tag_ptr(ret_conv, true);
19341 }
19342
19343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19344         void* e_ptr = untag_ptr(e);
19345         CHECK_ACCESS(e_ptr);
19346         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19347         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19348         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19349         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
19350         return tag_ptr(ret_conv, true);
19351 }
19352
19353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19354         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
19355         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
19356         return ret_conv;
19357 }
19358
19359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19360         if (!ptr_is_owned(_res)) return;
19361         void* _res_ptr = untag_ptr(_res);
19362         CHECK_ACCESS(_res_ptr);
19363         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
19364         FREE(untag_ptr(_res));
19365         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
19366 }
19367
19368 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
19369         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19370         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
19371         return tag_ptr(ret_conv, true);
19372 }
19373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19374         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
19375         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
19376         return ret_conv;
19377 }
19378
19379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19380         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
19381         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19382         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
19383         return tag_ptr(ret_conv, true);
19384 }
19385
19386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19387         LDKRoutingFees o_conv;
19388         o_conv.inner = untag_ptr(o);
19389         o_conv.is_owned = ptr_is_owned(o);
19390         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19391         o_conv = RoutingFees_clone(&o_conv);
19392         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19393         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
19394         return tag_ptr(ret_conv, true);
19395 }
19396
19397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19398         void* e_ptr = untag_ptr(e);
19399         CHECK_ACCESS(e_ptr);
19400         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19401         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19402         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19403         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
19404         return tag_ptr(ret_conv, true);
19405 }
19406
19407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19408         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
19409         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
19410         return ret_conv;
19411 }
19412
19413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19414         if (!ptr_is_owned(_res)) return;
19415         void* _res_ptr = untag_ptr(_res);
19416         CHECK_ACCESS(_res_ptr);
19417         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
19418         FREE(untag_ptr(_res));
19419         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
19420 }
19421
19422 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
19423         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19424         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
19425         return tag_ptr(ret_conv, true);
19426 }
19427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19428         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
19429         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
19430         return ret_conv;
19431 }
19432
19433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19434         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
19435         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19436         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
19437         return tag_ptr(ret_conv, true);
19438 }
19439
19440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19441         LDKCVec_NetAddressZ _res_constr;
19442         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19443         if (_res_constr.datalen > 0)
19444                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19445         else
19446                 _res_constr.data = NULL;
19447         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19448         for (size_t m = 0; m < _res_constr.datalen; m++) {
19449                 int64_t _res_conv_12 = _res_vals[m];
19450                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
19451                 CHECK_ACCESS(_res_conv_12_ptr);
19452                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
19453                 FREE(untag_ptr(_res_conv_12));
19454                 _res_constr.data[m] = _res_conv_12_conv;
19455         }
19456         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19457         CVec_NetAddressZ_free(_res_constr);
19458 }
19459
19460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19461         LDKNodeAnnouncementInfo o_conv;
19462         o_conv.inner = untag_ptr(o);
19463         o_conv.is_owned = ptr_is_owned(o);
19464         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19465         o_conv = NodeAnnouncementInfo_clone(&o_conv);
19466         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19467         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
19468         return tag_ptr(ret_conv, true);
19469 }
19470
19471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19472         void* e_ptr = untag_ptr(e);
19473         CHECK_ACCESS(e_ptr);
19474         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19475         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19476         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19477         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
19478         return tag_ptr(ret_conv, true);
19479 }
19480
19481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19482         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
19483         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
19484         return ret_conv;
19485 }
19486
19487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19488         if (!ptr_is_owned(_res)) return;
19489         void* _res_ptr = untag_ptr(_res);
19490         CHECK_ACCESS(_res_ptr);
19491         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
19492         FREE(untag_ptr(_res));
19493         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
19494 }
19495
19496 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
19497         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19498         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
19499         return tag_ptr(ret_conv, true);
19500 }
19501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19502         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
19503         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
19504         return ret_conv;
19505 }
19506
19507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19508         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
19509         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19510         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
19511         return tag_ptr(ret_conv, true);
19512 }
19513
19514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19515         LDKNodeAlias o_conv;
19516         o_conv.inner = untag_ptr(o);
19517         o_conv.is_owned = ptr_is_owned(o);
19518         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19519         o_conv = NodeAlias_clone(&o_conv);
19520         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19521         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
19522         return tag_ptr(ret_conv, true);
19523 }
19524
19525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19526         void* e_ptr = untag_ptr(e);
19527         CHECK_ACCESS(e_ptr);
19528         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19529         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19530         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19531         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
19532         return tag_ptr(ret_conv, true);
19533 }
19534
19535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19536         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
19537         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
19538         return ret_conv;
19539 }
19540
19541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19542         if (!ptr_is_owned(_res)) return;
19543         void* _res_ptr = untag_ptr(_res);
19544         CHECK_ACCESS(_res_ptr);
19545         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
19546         FREE(untag_ptr(_res));
19547         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
19548 }
19549
19550 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
19551         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19552         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
19553         return tag_ptr(ret_conv, true);
19554 }
19555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19556         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
19557         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
19558         return ret_conv;
19559 }
19560
19561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19562         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
19563         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19564         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
19565         return tag_ptr(ret_conv, true);
19566 }
19567
19568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19569         LDKNodeInfo o_conv;
19570         o_conv.inner = untag_ptr(o);
19571         o_conv.is_owned = ptr_is_owned(o);
19572         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19573         o_conv = NodeInfo_clone(&o_conv);
19574         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19575         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
19576         return tag_ptr(ret_conv, true);
19577 }
19578
19579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19580         void* e_ptr = untag_ptr(e);
19581         CHECK_ACCESS(e_ptr);
19582         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19583         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19584         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19585         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
19586         return tag_ptr(ret_conv, true);
19587 }
19588
19589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19590         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
19591         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
19592         return ret_conv;
19593 }
19594
19595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19596         if (!ptr_is_owned(_res)) return;
19597         void* _res_ptr = untag_ptr(_res);
19598         CHECK_ACCESS(_res_ptr);
19599         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
19600         FREE(untag_ptr(_res));
19601         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
19602 }
19603
19604 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
19605         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19606         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
19607         return tag_ptr(ret_conv, true);
19608 }
19609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19610         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
19611         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
19612         return ret_conv;
19613 }
19614
19615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19616         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
19617         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19618         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
19619         return tag_ptr(ret_conv, true);
19620 }
19621
19622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19623         LDKNetworkGraph o_conv;
19624         o_conv.inner = untag_ptr(o);
19625         o_conv.is_owned = ptr_is_owned(o);
19626         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19627         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
19628         
19629         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19630         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
19631         return tag_ptr(ret_conv, true);
19632 }
19633
19634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19635         void* e_ptr = untag_ptr(e);
19636         CHECK_ACCESS(e_ptr);
19637         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19638         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19639         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19640         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
19641         return tag_ptr(ret_conv, true);
19642 }
19643
19644 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19645         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
19646         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
19647         return ret_conv;
19648 }
19649
19650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19651         if (!ptr_is_owned(_res)) return;
19652         void* _res_ptr = untag_ptr(_res);
19653         CHECK_ACCESS(_res_ptr);
19654         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
19655         FREE(untag_ptr(_res));
19656         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
19657 }
19658
19659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
19660         LDKCVec_NetAddressZ o_constr;
19661         o_constr.datalen = (*env)->GetArrayLength(env, o);
19662         if (o_constr.datalen > 0)
19663                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19664         else
19665                 o_constr.data = NULL;
19666         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19667         for (size_t m = 0; m < o_constr.datalen; m++) {
19668                 int64_t o_conv_12 = o_vals[m];
19669                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
19670                 CHECK_ACCESS(o_conv_12_ptr);
19671                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
19672                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
19673                 o_constr.data[m] = o_conv_12_conv;
19674         }
19675         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19676         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19677         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
19678         int64_t ret_ref = tag_ptr(ret_copy, true);
19679         return ret_ref;
19680 }
19681
19682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
19683         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19684         *ret_copy = COption_CVec_NetAddressZZ_none();
19685         int64_t ret_ref = tag_ptr(ret_copy, true);
19686         return ret_ref;
19687 }
19688
19689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19690         if (!ptr_is_owned(_res)) return;
19691         void* _res_ptr = untag_ptr(_res);
19692         CHECK_ACCESS(_res_ptr);
19693         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
19694         FREE(untag_ptr(_res));
19695         COption_CVec_NetAddressZZ_free(_res_conv);
19696 }
19697
19698 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
19699         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19700         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
19701         int64_t ret_ref = tag_ptr(ret_copy, true);
19702         return ret_ref;
19703 }
19704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19705         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
19706         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
19707         return ret_conv;
19708 }
19709
19710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19711         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
19712         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19713         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
19714         int64_t ret_ref = tag_ptr(ret_copy, true);
19715         return ret_ref;
19716 }
19717
19718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19719         LDKDelayedPaymentOutputDescriptor o_conv;
19720         o_conv.inner = untag_ptr(o);
19721         o_conv.is_owned = ptr_is_owned(o);
19722         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19723         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
19724         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19725         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19726         return tag_ptr(ret_conv, true);
19727 }
19728
19729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19730         void* e_ptr = untag_ptr(e);
19731         CHECK_ACCESS(e_ptr);
19732         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19733         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19734         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19735         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19736         return tag_ptr(ret_conv, true);
19737 }
19738
19739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19740         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19741         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19742         return ret_conv;
19743 }
19744
19745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19746         if (!ptr_is_owned(_res)) return;
19747         void* _res_ptr = untag_ptr(_res);
19748         CHECK_ACCESS(_res_ptr);
19749         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19750         FREE(untag_ptr(_res));
19751         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19752 }
19753
19754 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19755         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19756         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19757         return tag_ptr(ret_conv, true);
19758 }
19759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19760         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19761         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19762         return ret_conv;
19763 }
19764
19765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19766         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19767         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19768         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19769         return tag_ptr(ret_conv, true);
19770 }
19771
19772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19773         LDKStaticPaymentOutputDescriptor o_conv;
19774         o_conv.inner = untag_ptr(o);
19775         o_conv.is_owned = ptr_is_owned(o);
19776         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19777         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
19778         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19779         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19780         return tag_ptr(ret_conv, true);
19781 }
19782
19783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19784         void* e_ptr = untag_ptr(e);
19785         CHECK_ACCESS(e_ptr);
19786         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19787         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19788         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19789         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19790         return tag_ptr(ret_conv, true);
19791 }
19792
19793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19794         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19795         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19796         return ret_conv;
19797 }
19798
19799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19800         if (!ptr_is_owned(_res)) return;
19801         void* _res_ptr = untag_ptr(_res);
19802         CHECK_ACCESS(_res_ptr);
19803         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19804         FREE(untag_ptr(_res));
19805         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19806 }
19807
19808 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19809         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19810         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19811         return tag_ptr(ret_conv, true);
19812 }
19813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19814         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19815         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19816         return ret_conv;
19817 }
19818
19819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19820         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19821         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19822         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19823         return tag_ptr(ret_conv, true);
19824 }
19825
19826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19827         void* o_ptr = untag_ptr(o);
19828         CHECK_ACCESS(o_ptr);
19829         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
19830         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
19831         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19832         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
19833         return tag_ptr(ret_conv, true);
19834 }
19835
19836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19837         void* e_ptr = untag_ptr(e);
19838         CHECK_ACCESS(e_ptr);
19839         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19840         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19841         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19842         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
19843         return tag_ptr(ret_conv, true);
19844 }
19845
19846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19847         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19848         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19849         return ret_conv;
19850 }
19851
19852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19853         if (!ptr_is_owned(_res)) return;
19854         void* _res_ptr = untag_ptr(_res);
19855         CHECK_ACCESS(_res_ptr);
19856         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
19857         FREE(untag_ptr(_res));
19858         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
19859 }
19860
19861 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19862         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19863         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
19864         return tag_ptr(ret_conv, true);
19865 }
19866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19867         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19868         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19869         return ret_conv;
19870 }
19871
19872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19873         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19874         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19875         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
19876         return tag_ptr(ret_conv, true);
19877 }
19878
19879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19880         LDKCVec_PaymentPreimageZ _res_constr;
19881         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19882         if (_res_constr.datalen > 0)
19883                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
19884         else
19885                 _res_constr.data = NULL;
19886         for (size_t i = 0; i < _res_constr.datalen; i++) {
19887                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19888                 LDKThirtyTwoBytes _res_conv_8_ref;
19889                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19890                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19891                 _res_constr.data[i] = _res_conv_8_ref;
19892         }
19893         CVec_PaymentPreimageZ_free(_res_constr);
19894 }
19895
19896 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
19897         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19898         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
19899         return tag_ptr(ret_conv, true);
19900 }
19901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19902         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
19903         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
19904         return ret_conv;
19905 }
19906
19907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19908         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
19909         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19910         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
19911         return tag_ptr(ret_conv, true);
19912 }
19913
19914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
19915         LDKSignature a_ref;
19916         CHECK((*env)->GetArrayLength(env, a) == 64);
19917         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19918         LDKCVec_SignatureZ b_constr;
19919         b_constr.datalen = (*env)->GetArrayLength(env, b);
19920         if (b_constr.datalen > 0)
19921                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19922         else
19923                 b_constr.data = NULL;
19924         for (size_t i = 0; i < b_constr.datalen; i++) {
19925                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
19926                 LDKSignature b_conv_8_ref;
19927                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
19928                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
19929                 b_constr.data[i] = b_conv_8_ref;
19930         }
19931         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19932         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
19933         return tag_ptr(ret_conv, true);
19934 }
19935
19936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19937         if (!ptr_is_owned(_res)) return;
19938         void* _res_ptr = untag_ptr(_res);
19939         CHECK_ACCESS(_res_ptr);
19940         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
19941         FREE(untag_ptr(_res));
19942         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
19943 }
19944
19945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19946         void* o_ptr = untag_ptr(o);
19947         CHECK_ACCESS(o_ptr);
19948         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
19949         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
19950         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19951         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
19952         return tag_ptr(ret_conv, true);
19953 }
19954
19955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
19956         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19957         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
19958         return tag_ptr(ret_conv, true);
19959 }
19960
19961 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19962         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
19963         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
19964         return ret_conv;
19965 }
19966
19967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19968         if (!ptr_is_owned(_res)) return;
19969         void* _res_ptr = untag_ptr(_res);
19970         CHECK_ACCESS(_res_ptr);
19971         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
19972         FREE(untag_ptr(_res));
19973         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
19974 }
19975
19976 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
19977         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19978         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
19979         return tag_ptr(ret_conv, true);
19980 }
19981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19982         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
19983         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
19984         return ret_conv;
19985 }
19986
19987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19988         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
19989         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19990         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
19991         return tag_ptr(ret_conv, true);
19992 }
19993
19994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19995         LDKSignature o_ref;
19996         CHECK((*env)->GetArrayLength(env, o) == 64);
19997         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
19998         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19999         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
20000         return tag_ptr(ret_conv, true);
20001 }
20002
20003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20004         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20005         *ret_conv = CResult_SignatureNoneZ_err();
20006         return tag_ptr(ret_conv, true);
20007 }
20008
20009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20010         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
20011         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
20012         return ret_conv;
20013 }
20014
20015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20016         if (!ptr_is_owned(_res)) return;
20017         void* _res_ptr = untag_ptr(_res);
20018         CHECK_ACCESS(_res_ptr);
20019         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
20020         FREE(untag_ptr(_res));
20021         CResult_SignatureNoneZ_free(_res_conv);
20022 }
20023
20024 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
20025         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20026         *ret_conv = CResult_SignatureNoneZ_clone(arg);
20027         return tag_ptr(ret_conv, true);
20028 }
20029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20030         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
20031         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
20032         return ret_conv;
20033 }
20034
20035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20036         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
20037         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20038         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
20039         return tag_ptr(ret_conv, true);
20040 }
20041
20042 static inline uint64_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
20043         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
20044         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
20045         return tag_ptr(ret_conv, true);
20046 }
20047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20048         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(arg);
20049         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
20050         return ret_conv;
20051 }
20052
20053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20054         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(orig);
20055         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
20056         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
20057         return tag_ptr(ret_conv, true);
20058 }
20059
20060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20061         LDKSignature a_ref;
20062         CHECK((*env)->GetArrayLength(env, a) == 64);
20063         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
20064         LDKSignature b_ref;
20065         CHECK((*env)->GetArrayLength(env, b) == 64);
20066         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
20067         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
20068         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
20069         return tag_ptr(ret_conv, true);
20070 }
20071
20072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20073         if (!ptr_is_owned(_res)) return;
20074         void* _res_ptr = untag_ptr(_res);
20075         CHECK_ACCESS(_res_ptr);
20076         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
20077         FREE(untag_ptr(_res));
20078         C2Tuple_SignatureSignatureZ_free(_res_conv);
20079 }
20080
20081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20082         void* o_ptr = untag_ptr(o);
20083         CHECK_ACCESS(o_ptr);
20084         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
20085         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)untag_ptr(o));
20086         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20087         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
20088         return tag_ptr(ret_conv, true);
20089 }
20090
20091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
20092         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20093         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
20094         return tag_ptr(ret_conv, true);
20095 }
20096
20097 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20098         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(o);
20099         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
20100         return ret_conv;
20101 }
20102
20103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20104         if (!ptr_is_owned(_res)) return;
20105         void* _res_ptr = untag_ptr(_res);
20106         CHECK_ACCESS(_res_ptr);
20107         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
20108         FREE(untag_ptr(_res));
20109         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
20110 }
20111
20112 static inline uint64_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
20113         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20114         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
20115         return tag_ptr(ret_conv, true);
20116 }
20117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20118         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(arg);
20119         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
20120         return ret_conv;
20121 }
20122
20123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20124         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(orig);
20125         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20126         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
20127         return tag_ptr(ret_conv, true);
20128 }
20129
20130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20131         LDKSecretKey o_ref;
20132         CHECK((*env)->GetArrayLength(env, o) == 32);
20133         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
20134         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20135         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
20136         return tag_ptr(ret_conv, true);
20137 }
20138
20139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
20140         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20141         *ret_conv = CResult_SecretKeyNoneZ_err();
20142         return tag_ptr(ret_conv, true);
20143 }
20144
20145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20146         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(o);
20147         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
20148         return ret_conv;
20149 }
20150
20151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20152         if (!ptr_is_owned(_res)) return;
20153         void* _res_ptr = untag_ptr(_res);
20154         CHECK_ACCESS(_res_ptr);
20155         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
20156         FREE(untag_ptr(_res));
20157         CResult_SecretKeyNoneZ_free(_res_conv);
20158 }
20159
20160 static inline uint64_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
20161         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20162         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
20163         return tag_ptr(ret_conv, true);
20164 }
20165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20166         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(arg);
20167         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
20168         return ret_conv;
20169 }
20170
20171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20172         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(orig);
20173         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20174         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
20175         return tag_ptr(ret_conv, true);
20176 }
20177
20178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20179         LDKPublicKey o_ref;
20180         CHECK((*env)->GetArrayLength(env, o) == 33);
20181         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
20182         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20183         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
20184         return tag_ptr(ret_conv, true);
20185 }
20186
20187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1err(JNIEnv *env, jclass clz) {
20188         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20189         *ret_conv = CResult_PublicKeyNoneZ_err();
20190         return tag_ptr(ret_conv, true);
20191 }
20192
20193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20194         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
20195         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
20196         return ret_conv;
20197 }
20198
20199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20200         if (!ptr_is_owned(_res)) return;
20201         void* _res_ptr = untag_ptr(_res);
20202         CHECK_ACCESS(_res_ptr);
20203         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
20204         FREE(untag_ptr(_res));
20205         CResult_PublicKeyNoneZ_free(_res_conv);
20206 }
20207
20208 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
20209         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20210         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
20211         return tag_ptr(ret_conv, true);
20212 }
20213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20214         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
20215         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
20216         return ret_conv;
20217 }
20218
20219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20220         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
20221         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20222         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
20223         return tag_ptr(ret_conv, true);
20224 }
20225
20226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20227         void* o_ptr = untag_ptr(o);
20228         CHECK_ACCESS(o_ptr);
20229         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
20230         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
20231         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20232         *ret_copy = COption_ScalarZ_some(o_conv);
20233         int64_t ret_ref = tag_ptr(ret_copy, true);
20234         return ret_ref;
20235 }
20236
20237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
20238         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20239         *ret_copy = COption_ScalarZ_none();
20240         int64_t ret_ref = tag_ptr(ret_copy, true);
20241         return ret_ref;
20242 }
20243
20244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20245         if (!ptr_is_owned(_res)) return;
20246         void* _res_ptr = untag_ptr(_res);
20247         CHECK_ACCESS(_res_ptr);
20248         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
20249         FREE(untag_ptr(_res));
20250         COption_ScalarZ_free(_res_conv);
20251 }
20252
20253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20254         LDKThirtyTwoBytes o_ref;
20255         CHECK((*env)->GetArrayLength(env, o) == 32);
20256         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20257         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20258         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
20259         return tag_ptr(ret_conv, true);
20260 }
20261
20262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20263         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20264         *ret_conv = CResult_SharedSecretNoneZ_err();
20265         return tag_ptr(ret_conv, true);
20266 }
20267
20268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20269         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
20270         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
20271         return ret_conv;
20272 }
20273
20274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20275         if (!ptr_is_owned(_res)) return;
20276         void* _res_ptr = untag_ptr(_res);
20277         CHECK_ACCESS(_res_ptr);
20278         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
20279         FREE(untag_ptr(_res));
20280         CResult_SharedSecretNoneZ_free(_res_conv);
20281 }
20282
20283 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
20284         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20285         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
20286         return tag_ptr(ret_conv, true);
20287 }
20288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20289         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
20290         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
20291         return ret_conv;
20292 }
20293
20294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20295         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
20296         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20297         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
20298         return tag_ptr(ret_conv, true);
20299 }
20300
20301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20302         void* o_ptr = untag_ptr(o);
20303         CHECK_ACCESS(o_ptr);
20304         LDKSign o_conv = *(LDKSign*)(o_ptr);
20305         if (o_conv.free == LDKSign_JCalls_free) {
20306                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20307                 LDKSign_JCalls_cloned(&o_conv);
20308         }
20309         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20310         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
20311         return tag_ptr(ret_conv, true);
20312 }
20313
20314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20315         void* e_ptr = untag_ptr(e);
20316         CHECK_ACCESS(e_ptr);
20317         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20318         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20319         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20320         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
20321         return tag_ptr(ret_conv, true);
20322 }
20323
20324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20325         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(o);
20326         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
20327         return ret_conv;
20328 }
20329
20330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20331         if (!ptr_is_owned(_res)) return;
20332         void* _res_ptr = untag_ptr(_res);
20333         CHECK_ACCESS(_res_ptr);
20334         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
20335         FREE(untag_ptr(_res));
20336         CResult_SignDecodeErrorZ_free(_res_conv);
20337 }
20338
20339 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
20340         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20341         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
20342         return tag_ptr(ret_conv, true);
20343 }
20344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20345         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(arg);
20346         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
20347         return ret_conv;
20348 }
20349
20350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20351         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(orig);
20352         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20353         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
20354         return tag_ptr(ret_conv, true);
20355 }
20356
20357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1U5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20358         LDKCVec_U5Z _res_constr;
20359         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20360         if (_res_constr.datalen > 0)
20361                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
20362         else
20363                 _res_constr.data = NULL;
20364         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
20365         for (size_t h = 0; h < _res_constr.datalen; h++) {
20366                 int8_t _res_conv_7 = _res_vals[h];
20367                 
20368                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
20369         }
20370         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
20371         CVec_U5Z_free(_res_constr);
20372 }
20373
20374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20375         LDKRecoverableSignature o_ref;
20376         CHECK((*env)->GetArrayLength(env, o) == 68);
20377         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
20378         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20379         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
20380         return tag_ptr(ret_conv, true);
20381 }
20382
20383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20384         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20385         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
20386         return tag_ptr(ret_conv, true);
20387 }
20388
20389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20390         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
20391         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
20392         return ret_conv;
20393 }
20394
20395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20396         if (!ptr_is_owned(_res)) return;
20397         void* _res_ptr = untag_ptr(_res);
20398         CHECK_ACCESS(_res_ptr);
20399         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
20400         FREE(untag_ptr(_res));
20401         CResult_RecoverableSignatureNoneZ_free(_res_conv);
20402 }
20403
20404 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
20405         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20406         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
20407         return tag_ptr(ret_conv, true);
20408 }
20409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20410         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
20411         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
20412         return ret_conv;
20413 }
20414
20415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20416         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
20417         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20418         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
20419         return tag_ptr(ret_conv, true);
20420 }
20421
20422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
20423         LDKCVec_u8Z _res_ref;
20424         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
20425         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
20426         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
20427         CVec_u8Z_free(_res_ref);
20428 }
20429
20430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20431         LDKCVec_CVec_u8ZZ _res_constr;
20432         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20433         if (_res_constr.datalen > 0)
20434                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
20435         else
20436                 _res_constr.data = NULL;
20437         for (size_t i = 0; i < _res_constr.datalen; i++) {
20438                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20439                 LDKCVec_u8Z _res_conv_8_ref;
20440                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
20441                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
20442                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
20443                 _res_constr.data[i] = _res_conv_8_ref;
20444         }
20445         CVec_CVec_u8ZZ_free(_res_constr);
20446 }
20447
20448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
20449         LDKCVec_CVec_u8ZZ o_constr;
20450         o_constr.datalen = (*env)->GetArrayLength(env, o);
20451         if (o_constr.datalen > 0)
20452                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
20453         else
20454                 o_constr.data = NULL;
20455         for (size_t i = 0; i < o_constr.datalen; i++) {
20456                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
20457                 LDKCVec_u8Z o_conv_8_ref;
20458                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
20459                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
20460                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
20461                 o_constr.data[i] = o_conv_8_ref;
20462         }
20463         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20464         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
20465         return tag_ptr(ret_conv, true);
20466 }
20467
20468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
20469         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20470         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
20471         return tag_ptr(ret_conv, true);
20472 }
20473
20474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20475         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
20476         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
20477         return ret_conv;
20478 }
20479
20480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20481         if (!ptr_is_owned(_res)) return;
20482         void* _res_ptr = untag_ptr(_res);
20483         CHECK_ACCESS(_res_ptr);
20484         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
20485         FREE(untag_ptr(_res));
20486         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
20487 }
20488
20489 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
20490         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20491         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
20492         return tag_ptr(ret_conv, true);
20493 }
20494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20495         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
20496         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
20497         return ret_conv;
20498 }
20499
20500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20501         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
20502         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20503         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
20504         return tag_ptr(ret_conv, true);
20505 }
20506
20507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20508         LDKInMemorySigner o_conv;
20509         o_conv.inner = untag_ptr(o);
20510         o_conv.is_owned = ptr_is_owned(o);
20511         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20512         o_conv = InMemorySigner_clone(&o_conv);
20513         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20514         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
20515         return tag_ptr(ret_conv, true);
20516 }
20517
20518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20519         void* e_ptr = untag_ptr(e);
20520         CHECK_ACCESS(e_ptr);
20521         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20522         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20523         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20524         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
20525         return tag_ptr(ret_conv, true);
20526 }
20527
20528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20529         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
20530         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
20531         return ret_conv;
20532 }
20533
20534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20535         if (!ptr_is_owned(_res)) return;
20536         void* _res_ptr = untag_ptr(_res);
20537         CHECK_ACCESS(_res_ptr);
20538         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
20539         FREE(untag_ptr(_res));
20540         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
20541 }
20542
20543 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
20544         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20545         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
20546         return tag_ptr(ret_conv, true);
20547 }
20548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20549         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
20550         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
20551         return ret_conv;
20552 }
20553
20554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20555         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
20556         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20557         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
20558         return tag_ptr(ret_conv, true);
20559 }
20560
20561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20562         LDKCVec_TxOutZ _res_constr;
20563         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20564         if (_res_constr.datalen > 0)
20565                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20566         else
20567                 _res_constr.data = NULL;
20568         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20569         for (size_t h = 0; h < _res_constr.datalen; h++) {
20570                 int64_t _res_conv_7 = _res_vals[h];
20571                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
20572                 CHECK_ACCESS(_res_conv_7_ptr);
20573                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
20574                 FREE(untag_ptr(_res_conv_7));
20575                 _res_constr.data[h] = _res_conv_7_conv;
20576         }
20577         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20578         CVec_TxOutZ_free(_res_constr);
20579 }
20580
20581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20582         LDKTransaction o_ref;
20583         o_ref.datalen = (*env)->GetArrayLength(env, o);
20584         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
20585         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
20586         o_ref.data_is_owned = true;
20587         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20588         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
20589         return tag_ptr(ret_conv, true);
20590 }
20591
20592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
20593         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20594         *ret_conv = CResult_TransactionNoneZ_err();
20595         return tag_ptr(ret_conv, true);
20596 }
20597
20598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20599         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
20600         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
20601         return ret_conv;
20602 }
20603
20604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20605         if (!ptr_is_owned(_res)) return;
20606         void* _res_ptr = untag_ptr(_res);
20607         CHECK_ACCESS(_res_ptr);
20608         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
20609         FREE(untag_ptr(_res));
20610         CResult_TransactionNoneZ_free(_res_conv);
20611 }
20612
20613 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
20614         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20615         *ret_conv = CResult_TransactionNoneZ_clone(arg);
20616         return tag_ptr(ret_conv, true);
20617 }
20618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20619         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
20620         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
20621         return ret_conv;
20622 }
20623
20624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20625         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
20626         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20627         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
20628         return tag_ptr(ret_conv, true);
20629 }
20630
20631 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
20632         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20633         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
20634         return tag_ptr(ret_conv, true);
20635 }
20636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20637         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
20638         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
20639         return ret_conv;
20640 }
20641
20642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20643         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
20644         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20645         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
20646         return tag_ptr(ret_conv, true);
20647 }
20648
20649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20650         LDKThirtyTwoBytes a_ref;
20651         CHECK((*env)->GetArrayLength(env, a) == 32);
20652         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20653         LDKChannelMonitor b_conv;
20654         b_conv.inner = untag_ptr(b);
20655         b_conv.is_owned = ptr_is_owned(b);
20656         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20657         b_conv = ChannelMonitor_clone(&b_conv);
20658         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20659         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
20660         return tag_ptr(ret_conv, true);
20661 }
20662
20663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20664         if (!ptr_is_owned(_res)) return;
20665         void* _res_ptr = untag_ptr(_res);
20666         CHECK_ACCESS(_res_ptr);
20667         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
20668         FREE(untag_ptr(_res));
20669         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
20670 }
20671
20672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20673         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
20674         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20675         if (_res_constr.datalen > 0)
20676                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20677         else
20678                 _res_constr.data = NULL;
20679         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20680         for (size_t j = 0; j < _res_constr.datalen; j++) {
20681                 int64_t _res_conv_35 = _res_vals[j];
20682                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
20683                 CHECK_ACCESS(_res_conv_35_ptr);
20684                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
20685                 FREE(untag_ptr(_res_conv_35));
20686                 _res_constr.data[j] = _res_conv_35_conv;
20687         }
20688         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20689         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
20690 }
20691
20692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
20693         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
20694         o_constr.datalen = (*env)->GetArrayLength(env, o);
20695         if (o_constr.datalen > 0)
20696                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20697         else
20698                 o_constr.data = NULL;
20699         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20700         for (size_t j = 0; j < o_constr.datalen; j++) {
20701                 int64_t o_conv_35 = o_vals[j];
20702                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
20703                 CHECK_ACCESS(o_conv_35_ptr);
20704                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
20705                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
20706                 o_constr.data[j] = o_conv_35_conv;
20707         }
20708         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20709         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20710         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
20711         return tag_ptr(ret_conv, true);
20712 }
20713
20714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20715         LDKIOError e_conv = LDKIOError_from_java(env, e);
20716         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20717         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
20718         return tag_ptr(ret_conv, true);
20719 }
20720
20721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20722         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
20723         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
20724         return ret_conv;
20725 }
20726
20727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20728         if (!ptr_is_owned(_res)) return;
20729         void* _res_ptr = untag_ptr(_res);
20730         CHECK_ACCESS(_res_ptr);
20731         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
20732         FREE(untag_ptr(_res));
20733         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
20734 }
20735
20736 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
20737         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20738         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
20739         return tag_ptr(ret_conv, true);
20740 }
20741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20742         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
20743         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
20744         return ret_conv;
20745 }
20746
20747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20748         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
20749         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20750         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
20751         return tag_ptr(ret_conv, true);
20752 }
20753
20754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
20755         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20756         *ret_copy = COption_u16Z_some(o);
20757         int64_t ret_ref = tag_ptr(ret_copy, true);
20758         return ret_ref;
20759 }
20760
20761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
20762         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20763         *ret_copy = COption_u16Z_none();
20764         int64_t ret_ref = tag_ptr(ret_copy, true);
20765         return ret_ref;
20766 }
20767
20768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
20769         if (!ptr_is_owned(_res)) return;
20770         void* _res_ptr = untag_ptr(_res);
20771         CHECK_ACCESS(_res_ptr);
20772         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
20773         FREE(untag_ptr(_res));
20774         COption_u16Z_free(_res_conv);
20775 }
20776
20777 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
20778         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20779         *ret_copy = COption_u16Z_clone(arg);
20780         int64_t ret_ref = tag_ptr(ret_copy, true);
20781         return ret_ref;
20782 }
20783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20784         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
20785         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
20786         return ret_conv;
20787 }
20788
20789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20790         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
20791         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20792         *ret_copy = COption_u16Z_clone(orig_conv);
20793         int64_t ret_ref = tag_ptr(ret_copy, true);
20794         return ret_ref;
20795 }
20796
20797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
20798         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20799         *ret_conv = CResult_NoneAPIErrorZ_ok();
20800         return tag_ptr(ret_conv, true);
20801 }
20802
20803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20804         void* e_ptr = untag_ptr(e);
20805         CHECK_ACCESS(e_ptr);
20806         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20807         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20808         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20809         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
20810         return tag_ptr(ret_conv, true);
20811 }
20812
20813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20814         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
20815         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
20816         return ret_conv;
20817 }
20818
20819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20820         if (!ptr_is_owned(_res)) return;
20821         void* _res_ptr = untag_ptr(_res);
20822         CHECK_ACCESS(_res_ptr);
20823         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
20824         FREE(untag_ptr(_res));
20825         CResult_NoneAPIErrorZ_free(_res_conv);
20826 }
20827
20828 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
20829         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20830         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
20831         return tag_ptr(ret_conv, true);
20832 }
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20834         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
20835         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
20836         return ret_conv;
20837 }
20838
20839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20840         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
20841         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20842         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
20843         return tag_ptr(ret_conv, true);
20844 }
20845
20846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20847         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
20848         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20849         if (_res_constr.datalen > 0)
20850                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
20851         else
20852                 _res_constr.data = NULL;
20853         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20854         for (size_t w = 0; w < _res_constr.datalen; w++) {
20855                 int64_t _res_conv_22 = _res_vals[w];
20856                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
20857                 CHECK_ACCESS(_res_conv_22_ptr);
20858                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
20859                 FREE(untag_ptr(_res_conv_22));
20860                 _res_constr.data[w] = _res_conv_22_conv;
20861         }
20862         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20863         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
20864 }
20865
20866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20867         LDKCVec_APIErrorZ _res_constr;
20868         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20869         if (_res_constr.datalen > 0)
20870                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
20871         else
20872                 _res_constr.data = NULL;
20873         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20874         for (size_t k = 0; k < _res_constr.datalen; k++) {
20875                 int64_t _res_conv_10 = _res_vals[k];
20876                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
20877                 CHECK_ACCESS(_res_conv_10_ptr);
20878                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
20879                 FREE(untag_ptr(_res_conv_10));
20880                 _res_constr.data[k] = _res_conv_10_conv;
20881         }
20882         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20883         CVec_APIErrorZ_free(_res_constr);
20884 }
20885
20886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20887         LDKThirtyTwoBytes o_ref;
20888         CHECK((*env)->GetArrayLength(env, o) == 32);
20889         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20890         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20891         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
20892         return tag_ptr(ret_conv, true);
20893 }
20894
20895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20896         void* e_ptr = untag_ptr(e);
20897         CHECK_ACCESS(e_ptr);
20898         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20899         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20900         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20901         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
20902         return tag_ptr(ret_conv, true);
20903 }
20904
20905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20906         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
20907         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
20908         return ret_conv;
20909 }
20910
20911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20912         if (!ptr_is_owned(_res)) return;
20913         void* _res_ptr = untag_ptr(_res);
20914         CHECK_ACCESS(_res_ptr);
20915         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
20916         FREE(untag_ptr(_res));
20917         CResult__u832APIErrorZ_free(_res_conv);
20918 }
20919
20920 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
20921         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20922         *ret_conv = CResult__u832APIErrorZ_clone(arg);
20923         return tag_ptr(ret_conv, true);
20924 }
20925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20926         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
20927         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
20928         return ret_conv;
20929 }
20930
20931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20932         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
20933         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20934         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
20935         return tag_ptr(ret_conv, true);
20936 }
20937
20938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
20939         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20940         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20941         return tag_ptr(ret_conv, true);
20942 }
20943
20944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20945         void* e_ptr = untag_ptr(e);
20946         CHECK_ACCESS(e_ptr);
20947         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20948         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20949         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20950         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20951         return tag_ptr(ret_conv, true);
20952 }
20953
20954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20955         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20956         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20957         return ret_conv;
20958 }
20959
20960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20961         if (!ptr_is_owned(_res)) return;
20962         void* _res_ptr = untag_ptr(_res);
20963         CHECK_ACCESS(_res_ptr);
20964         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20965         FREE(untag_ptr(_res));
20966         CResult_NonePaymentSendFailureZ_free(_res_conv);
20967 }
20968
20969 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20970         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20971         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20972         return tag_ptr(ret_conv, true);
20973 }
20974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20975         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20976         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20977         return ret_conv;
20978 }
20979
20980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20981         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20982         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20983         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20984         return tag_ptr(ret_conv, true);
20985 }
20986
20987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20988         LDKThirtyTwoBytes o_ref;
20989         CHECK((*env)->GetArrayLength(env, o) == 32);
20990         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20991         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
20992         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
20993         return tag_ptr(ret_conv, true);
20994 }
20995
20996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20997         void* e_ptr = untag_ptr(e);
20998         CHECK_ACCESS(e_ptr);
20999         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21000         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21001         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21002         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
21003         return tag_ptr(ret_conv, true);
21004 }
21005
21006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21007         LDKCResult_PaymentHashPaymentSendFailureZ* o_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(o);
21008         jboolean ret_conv = CResult_PaymentHashPaymentSendFailureZ_is_ok(o_conv);
21009         return ret_conv;
21010 }
21011
21012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21013         if (!ptr_is_owned(_res)) return;
21014         void* _res_ptr = untag_ptr(_res);
21015         CHECK_ACCESS(_res_ptr);
21016         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(_res_ptr);
21017         FREE(untag_ptr(_res));
21018         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
21019 }
21020
21021 static inline uint64_t CResult_PaymentHashPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR arg) {
21022         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21023         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(arg);
21024         return tag_ptr(ret_conv, true);
21025 }
21026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21027         LDKCResult_PaymentHashPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(arg);
21028         int64_t ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone_ptr(arg_conv);
21029         return ret_conv;
21030 }
21031
21032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21033         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(orig);
21034         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21035         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
21036         return tag_ptr(ret_conv, true);
21037 }
21038
21039 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
21040         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21041         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
21042         return tag_ptr(ret_conv, true);
21043 }
21044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21045         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
21046         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
21047         return ret_conv;
21048 }
21049
21050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21051         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
21052         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21053         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
21054         return tag_ptr(ret_conv, true);
21055 }
21056
21057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21058         LDKThirtyTwoBytes a_ref;
21059         CHECK((*env)->GetArrayLength(env, a) == 32);
21060         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21061         LDKThirtyTwoBytes b_ref;
21062         CHECK((*env)->GetArrayLength(env, b) == 32);
21063         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21064         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21065         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
21066         return tag_ptr(ret_conv, true);
21067 }
21068
21069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21070         if (!ptr_is_owned(_res)) return;
21071         void* _res_ptr = untag_ptr(_res);
21072         CHECK_ACCESS(_res_ptr);
21073         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
21074         FREE(untag_ptr(_res));
21075         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
21076 }
21077
21078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21079         void* o_ptr = untag_ptr(o);
21080         CHECK_ACCESS(o_ptr);
21081         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
21082         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
21083         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21084         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
21085         return tag_ptr(ret_conv, true);
21086 }
21087
21088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21089         void* e_ptr = untag_ptr(e);
21090         CHECK_ACCESS(e_ptr);
21091         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21092         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21093         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21094         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
21095         return tag_ptr(ret_conv, true);
21096 }
21097
21098 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21099         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
21100         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
21101         return ret_conv;
21102 }
21103
21104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21105         if (!ptr_is_owned(_res)) return;
21106         void* _res_ptr = untag_ptr(_res);
21107         CHECK_ACCESS(_res_ptr);
21108         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
21109         FREE(untag_ptr(_res));
21110         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
21111 }
21112
21113 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
21114         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21115         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
21116         return tag_ptr(ret_conv, true);
21117 }
21118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21119         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
21120         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
21121         return ret_conv;
21122 }
21123
21124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21125         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
21126         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21127         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
21128         return tag_ptr(ret_conv, true);
21129 }
21130
21131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21132         LDKCVec_ThirtyTwoBytesZ _res_constr;
21133         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21134         if (_res_constr.datalen > 0)
21135                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
21136         else
21137                 _res_constr.data = NULL;
21138         for (size_t i = 0; i < _res_constr.datalen; i++) {
21139                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21140                 LDKThirtyTwoBytes _res_conv_8_ref;
21141                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
21142                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
21143                 _res_constr.data[i] = _res_conv_8_ref;
21144         }
21145         CVec_ThirtyTwoBytesZ_free(_res_constr);
21146 }
21147
21148 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
21149         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21150         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
21151         return tag_ptr(ret_conv, true);
21152 }
21153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21154         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
21155         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
21156         return ret_conv;
21157 }
21158
21159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21160         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
21161         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21162         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
21163         return tag_ptr(ret_conv, true);
21164 }
21165
21166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21167         LDKThirtyTwoBytes a_ref;
21168         CHECK((*env)->GetArrayLength(env, a) == 32);
21169         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21170         LDKThirtyTwoBytes b_ref;
21171         CHECK((*env)->GetArrayLength(env, b) == 32);
21172         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21173         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21174         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
21175         return tag_ptr(ret_conv, true);
21176 }
21177
21178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21179         if (!ptr_is_owned(_res)) return;
21180         void* _res_ptr = untag_ptr(_res);
21181         CHECK_ACCESS(_res_ptr);
21182         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
21183         FREE(untag_ptr(_res));
21184         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
21185 }
21186
21187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21188         void* o_ptr = untag_ptr(o);
21189         CHECK_ACCESS(o_ptr);
21190         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21191         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21192         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21193         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
21194         return tag_ptr(ret_conv, true);
21195 }
21196
21197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
21198         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21199         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
21200         return tag_ptr(ret_conv, true);
21201 }
21202
21203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21204         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
21205         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
21206         return ret_conv;
21207 }
21208
21209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21210         if (!ptr_is_owned(_res)) return;
21211         void* _res_ptr = untag_ptr(_res);
21212         CHECK_ACCESS(_res_ptr);
21213         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
21214         FREE(untag_ptr(_res));
21215         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
21216 }
21217
21218 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
21219         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21220         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
21221         return tag_ptr(ret_conv, true);
21222 }
21223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21224         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
21225         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
21226         return ret_conv;
21227 }
21228
21229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21230         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
21231         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21232         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
21233         return tag_ptr(ret_conv, true);
21234 }
21235
21236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21237         void* o_ptr = untag_ptr(o);
21238         CHECK_ACCESS(o_ptr);
21239         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21240         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21241         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21242         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
21243         return tag_ptr(ret_conv, true);
21244 }
21245
21246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21247         void* e_ptr = untag_ptr(e);
21248         CHECK_ACCESS(e_ptr);
21249         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21250         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21251         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21252         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
21253         return tag_ptr(ret_conv, true);
21254 }
21255
21256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21257         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
21258         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
21259         return ret_conv;
21260 }
21261
21262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21263         if (!ptr_is_owned(_res)) return;
21264         void* _res_ptr = untag_ptr(_res);
21265         CHECK_ACCESS(_res_ptr);
21266         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
21267         FREE(untag_ptr(_res));
21268         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
21269 }
21270
21271 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
21272         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21273         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
21274         return tag_ptr(ret_conv, true);
21275 }
21276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21277         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
21278         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
21279         return ret_conv;
21280 }
21281
21282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21283         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
21284         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21285         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
21286         return tag_ptr(ret_conv, true);
21287 }
21288
21289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21290         LDKThirtyTwoBytes o_ref;
21291         CHECK((*env)->GetArrayLength(env, o) == 32);
21292         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21293         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21294         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
21295         return tag_ptr(ret_conv, true);
21296 }
21297
21298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
21299         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21300         *ret_conv = CResult_PaymentSecretNoneZ_err();
21301         return tag_ptr(ret_conv, true);
21302 }
21303
21304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21305         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
21306         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
21307         return ret_conv;
21308 }
21309
21310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21311         if (!ptr_is_owned(_res)) return;
21312         void* _res_ptr = untag_ptr(_res);
21313         CHECK_ACCESS(_res_ptr);
21314         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
21315         FREE(untag_ptr(_res));
21316         CResult_PaymentSecretNoneZ_free(_res_conv);
21317 }
21318
21319 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
21320         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21321         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
21322         return tag_ptr(ret_conv, true);
21323 }
21324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21325         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
21326         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
21327         return ret_conv;
21328 }
21329
21330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21331         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
21332         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21333         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
21334         return tag_ptr(ret_conv, true);
21335 }
21336
21337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21338         LDKThirtyTwoBytes o_ref;
21339         CHECK((*env)->GetArrayLength(env, o) == 32);
21340         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21341         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21342         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
21343         return tag_ptr(ret_conv, true);
21344 }
21345
21346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21347         void* e_ptr = untag_ptr(e);
21348         CHECK_ACCESS(e_ptr);
21349         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21350         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21351         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21352         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
21353         return tag_ptr(ret_conv, true);
21354 }
21355
21356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21357         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
21358         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
21359         return ret_conv;
21360 }
21361
21362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21363         if (!ptr_is_owned(_res)) return;
21364         void* _res_ptr = untag_ptr(_res);
21365         CHECK_ACCESS(_res_ptr);
21366         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
21367         FREE(untag_ptr(_res));
21368         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
21369 }
21370
21371 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
21372         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21373         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
21374         return tag_ptr(ret_conv, true);
21375 }
21376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21377         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
21378         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
21379         return ret_conv;
21380 }
21381
21382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21383         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
21384         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21385         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
21386         return tag_ptr(ret_conv, true);
21387 }
21388
21389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21390         LDKThirtyTwoBytes o_ref;
21391         CHECK((*env)->GetArrayLength(env, o) == 32);
21392         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21393         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21394         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
21395         return tag_ptr(ret_conv, true);
21396 }
21397
21398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21399         void* e_ptr = untag_ptr(e);
21400         CHECK_ACCESS(e_ptr);
21401         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21402         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21403         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21404         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
21405         return tag_ptr(ret_conv, true);
21406 }
21407
21408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21409         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
21410         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
21411         return ret_conv;
21412 }
21413
21414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21415         if (!ptr_is_owned(_res)) return;
21416         void* _res_ptr = untag_ptr(_res);
21417         CHECK_ACCESS(_res_ptr);
21418         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
21419         FREE(untag_ptr(_res));
21420         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
21421 }
21422
21423 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
21424         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21425         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
21426         return tag_ptr(ret_conv, true);
21427 }
21428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21429         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
21430         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
21431         return ret_conv;
21432 }
21433
21434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21435         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
21436         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21437         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
21438         return tag_ptr(ret_conv, true);
21439 }
21440
21441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21442         LDKCounterpartyForwardingInfo o_conv;
21443         o_conv.inner = untag_ptr(o);
21444         o_conv.is_owned = ptr_is_owned(o);
21445         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21446         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
21447         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21448         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
21449         return tag_ptr(ret_conv, true);
21450 }
21451
21452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21453         void* e_ptr = untag_ptr(e);
21454         CHECK_ACCESS(e_ptr);
21455         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21456         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21457         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21458         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
21459         return tag_ptr(ret_conv, true);
21460 }
21461
21462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21463         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
21464         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
21465         return ret_conv;
21466 }
21467
21468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21469         if (!ptr_is_owned(_res)) return;
21470         void* _res_ptr = untag_ptr(_res);
21471         CHECK_ACCESS(_res_ptr);
21472         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
21473         FREE(untag_ptr(_res));
21474         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
21475 }
21476
21477 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
21478         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21479         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
21480         return tag_ptr(ret_conv, true);
21481 }
21482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21483         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
21484         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
21485         return ret_conv;
21486 }
21487
21488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21489         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
21490         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21491         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
21492         return tag_ptr(ret_conv, true);
21493 }
21494
21495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21496         LDKChannelCounterparty o_conv;
21497         o_conv.inner = untag_ptr(o);
21498         o_conv.is_owned = ptr_is_owned(o);
21499         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21500         o_conv = ChannelCounterparty_clone(&o_conv);
21501         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21502         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
21503         return tag_ptr(ret_conv, true);
21504 }
21505
21506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21507         void* e_ptr = untag_ptr(e);
21508         CHECK_ACCESS(e_ptr);
21509         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21510         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21511         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21512         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
21513         return tag_ptr(ret_conv, true);
21514 }
21515
21516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21517         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
21518         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
21519         return ret_conv;
21520 }
21521
21522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21523         if (!ptr_is_owned(_res)) return;
21524         void* _res_ptr = untag_ptr(_res);
21525         CHECK_ACCESS(_res_ptr);
21526         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
21527         FREE(untag_ptr(_res));
21528         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
21529 }
21530
21531 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
21532         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21533         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
21534         return tag_ptr(ret_conv, true);
21535 }
21536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21537         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
21538         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
21539         return ret_conv;
21540 }
21541
21542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21543         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
21544         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21545         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
21546         return tag_ptr(ret_conv, true);
21547 }
21548
21549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21550         LDKChannelDetails o_conv;
21551         o_conv.inner = untag_ptr(o);
21552         o_conv.is_owned = ptr_is_owned(o);
21553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21554         o_conv = ChannelDetails_clone(&o_conv);
21555         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21556         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
21557         return tag_ptr(ret_conv, true);
21558 }
21559
21560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21561         void* e_ptr = untag_ptr(e);
21562         CHECK_ACCESS(e_ptr);
21563         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21564         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21565         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21566         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
21567         return tag_ptr(ret_conv, true);
21568 }
21569
21570 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21571         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
21572         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
21573         return ret_conv;
21574 }
21575
21576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21577         if (!ptr_is_owned(_res)) return;
21578         void* _res_ptr = untag_ptr(_res);
21579         CHECK_ACCESS(_res_ptr);
21580         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
21581         FREE(untag_ptr(_res));
21582         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
21583 }
21584
21585 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
21586         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21587         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
21588         return tag_ptr(ret_conv, true);
21589 }
21590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21591         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
21592         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
21593         return ret_conv;
21594 }
21595
21596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21597         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
21598         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21599         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
21600         return tag_ptr(ret_conv, true);
21601 }
21602
21603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21604         LDKPhantomRouteHints o_conv;
21605         o_conv.inner = untag_ptr(o);
21606         o_conv.is_owned = ptr_is_owned(o);
21607         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21608         o_conv = PhantomRouteHints_clone(&o_conv);
21609         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21610         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
21611         return tag_ptr(ret_conv, true);
21612 }
21613
21614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21615         void* e_ptr = untag_ptr(e);
21616         CHECK_ACCESS(e_ptr);
21617         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21618         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21619         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21620         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
21621         return tag_ptr(ret_conv, true);
21622 }
21623
21624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21625         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
21626         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
21627         return ret_conv;
21628 }
21629
21630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21631         if (!ptr_is_owned(_res)) return;
21632         void* _res_ptr = untag_ptr(_res);
21633         CHECK_ACCESS(_res_ptr);
21634         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
21635         FREE(untag_ptr(_res));
21636         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
21637 }
21638
21639 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
21640         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21641         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
21642         return tag_ptr(ret_conv, true);
21643 }
21644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21645         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
21646         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
21647         return ret_conv;
21648 }
21649
21650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21651         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
21652         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21653         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
21654         return tag_ptr(ret_conv, true);
21655 }
21656
21657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21658         LDKCVec_ChannelMonitorZ _res_constr;
21659         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21660         if (_res_constr.datalen > 0)
21661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21662         else
21663                 _res_constr.data = NULL;
21664         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21665         for (size_t q = 0; q < _res_constr.datalen; q++) {
21666                 int64_t _res_conv_16 = _res_vals[q];
21667                 LDKChannelMonitor _res_conv_16_conv;
21668                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
21669                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
21670                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21671                 _res_constr.data[q] = _res_conv_16_conv;
21672         }
21673         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21674         CVec_ChannelMonitorZ_free(_res_constr);
21675 }
21676
21677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21678         LDKThirtyTwoBytes a_ref;
21679         CHECK((*env)->GetArrayLength(env, a) == 32);
21680         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21681         LDKChannelManager b_conv;
21682         b_conv.inner = untag_ptr(b);
21683         b_conv.is_owned = ptr_is_owned(b);
21684         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21685         // WARNING: we need a move here but no clone is available for LDKChannelManager
21686         
21687         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
21688         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
21689         return tag_ptr(ret_conv, true);
21690 }
21691
21692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21693         if (!ptr_is_owned(_res)) return;
21694         void* _res_ptr = untag_ptr(_res);
21695         CHECK_ACCESS(_res_ptr);
21696         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
21697         FREE(untag_ptr(_res));
21698         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
21699 }
21700
21701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21702         void* o_ptr = untag_ptr(o);
21703         CHECK_ACCESS(o_ptr);
21704         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
21705         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
21706         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21707         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
21708         return tag_ptr(ret_conv, true);
21709 }
21710
21711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21712         void* e_ptr = untag_ptr(e);
21713         CHECK_ACCESS(e_ptr);
21714         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21715         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21716         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21717         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
21718         return tag_ptr(ret_conv, true);
21719 }
21720
21721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21722         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
21723         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
21724         return ret_conv;
21725 }
21726
21727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21728         if (!ptr_is_owned(_res)) return;
21729         void* _res_ptr = untag_ptr(_res);
21730         CHECK_ACCESS(_res_ptr);
21731         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
21732         FREE(untag_ptr(_res));
21733         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
21734 }
21735
21736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21737         LDKChannelConfig o_conv;
21738         o_conv.inner = untag_ptr(o);
21739         o_conv.is_owned = ptr_is_owned(o);
21740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21741         o_conv = ChannelConfig_clone(&o_conv);
21742         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21743         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
21744         return tag_ptr(ret_conv, true);
21745 }
21746
21747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21748         void* e_ptr = untag_ptr(e);
21749         CHECK_ACCESS(e_ptr);
21750         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21751         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21752         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21753         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
21754         return tag_ptr(ret_conv, true);
21755 }
21756
21757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21758         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
21759         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
21760         return ret_conv;
21761 }
21762
21763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21764         if (!ptr_is_owned(_res)) return;
21765         void* _res_ptr = untag_ptr(_res);
21766         CHECK_ACCESS(_res_ptr);
21767         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
21768         FREE(untag_ptr(_res));
21769         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
21770 }
21771
21772 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
21773         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21774         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
21775         return tag_ptr(ret_conv, true);
21776 }
21777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21778         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
21779         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
21780         return ret_conv;
21781 }
21782
21783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21784         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
21785         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21786         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
21787         return tag_ptr(ret_conv, true);
21788 }
21789
21790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21791         LDKOutPoint o_conv;
21792         o_conv.inner = untag_ptr(o);
21793         o_conv.is_owned = ptr_is_owned(o);
21794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21795         o_conv = OutPoint_clone(&o_conv);
21796         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21797         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
21798         return tag_ptr(ret_conv, true);
21799 }
21800
21801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21802         void* e_ptr = untag_ptr(e);
21803         CHECK_ACCESS(e_ptr);
21804         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21805         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21806         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21807         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
21808         return tag_ptr(ret_conv, true);
21809 }
21810
21811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21812         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
21813         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
21814         return ret_conv;
21815 }
21816
21817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21818         if (!ptr_is_owned(_res)) return;
21819         void* _res_ptr = untag_ptr(_res);
21820         CHECK_ACCESS(_res_ptr);
21821         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
21822         FREE(untag_ptr(_res));
21823         CResult_OutPointDecodeErrorZ_free(_res_conv);
21824 }
21825
21826 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
21827         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21828         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
21829         return tag_ptr(ret_conv, true);
21830 }
21831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21832         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
21833         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
21834         return ret_conv;
21835 }
21836
21837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21838         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
21839         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21840         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
21841         return tag_ptr(ret_conv, true);
21842 }
21843
21844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21845         void* o_ptr = untag_ptr(o);
21846         CHECK_ACCESS(o_ptr);
21847         LDKType o_conv = *(LDKType*)(o_ptr);
21848         if (o_conv.free == LDKType_JCalls_free) {
21849                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21850                 LDKType_JCalls_cloned(&o_conv);
21851         }
21852         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21853         *ret_copy = COption_TypeZ_some(o_conv);
21854         int64_t ret_ref = tag_ptr(ret_copy, true);
21855         return ret_ref;
21856 }
21857
21858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
21859         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21860         *ret_copy = COption_TypeZ_none();
21861         int64_t ret_ref = tag_ptr(ret_copy, true);
21862         return ret_ref;
21863 }
21864
21865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21866         if (!ptr_is_owned(_res)) return;
21867         void* _res_ptr = untag_ptr(_res);
21868         CHECK_ACCESS(_res_ptr);
21869         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
21870         FREE(untag_ptr(_res));
21871         COption_TypeZ_free(_res_conv);
21872 }
21873
21874 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
21875         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21876         *ret_copy = COption_TypeZ_clone(arg);
21877         int64_t ret_ref = tag_ptr(ret_copy, true);
21878         return ret_ref;
21879 }
21880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21881         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
21882         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
21883         return ret_conv;
21884 }
21885
21886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21887         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
21888         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21889         *ret_copy = COption_TypeZ_clone(orig_conv);
21890         int64_t ret_ref = tag_ptr(ret_copy, true);
21891         return ret_ref;
21892 }
21893
21894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21895         void* o_ptr = untag_ptr(o);
21896         CHECK_ACCESS(o_ptr);
21897         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
21898         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
21899         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21900         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
21901         return tag_ptr(ret_conv, true);
21902 }
21903
21904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21905         void* e_ptr = untag_ptr(e);
21906         CHECK_ACCESS(e_ptr);
21907         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21908         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21909         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21910         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
21911         return tag_ptr(ret_conv, true);
21912 }
21913
21914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21915         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
21916         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
21917         return ret_conv;
21918 }
21919
21920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21921         if (!ptr_is_owned(_res)) return;
21922         void* _res_ptr = untag_ptr(_res);
21923         CHECK_ACCESS(_res_ptr);
21924         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
21925         FREE(untag_ptr(_res));
21926         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
21927 }
21928
21929 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
21930         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21931         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
21932         return tag_ptr(ret_conv, true);
21933 }
21934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21935         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
21936         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
21937         return ret_conv;
21938 }
21939
21940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21941         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
21942         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21943         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
21944         return tag_ptr(ret_conv, true);
21945 }
21946
21947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21948         LDKThirtyTwoBytes o_ref;
21949         CHECK((*env)->GetArrayLength(env, o) == 32);
21950         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21951         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21952         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
21953         return tag_ptr(ret_conv, true);
21954 }
21955
21956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21957         void* e_ptr = untag_ptr(e);
21958         CHECK_ACCESS(e_ptr);
21959         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
21960         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
21961         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21962         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
21963         return tag_ptr(ret_conv, true);
21964 }
21965
21966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21967         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
21968         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
21969         return ret_conv;
21970 }
21971
21972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21973         if (!ptr_is_owned(_res)) return;
21974         void* _res_ptr = untag_ptr(_res);
21975         CHECK_ACCESS(_res_ptr);
21976         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
21977         FREE(untag_ptr(_res));
21978         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
21979 }
21980
21981 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
21982         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21983         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
21984         return tag_ptr(ret_conv, true);
21985 }
21986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21987         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
21988         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
21989         return ret_conv;
21990 }
21991
21992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21993         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
21994         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21995         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
21996         return tag_ptr(ret_conv, true);
21997 }
21998
21999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1ok(JNIEnv *env, jclass clz) {
22000         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22001         *ret_conv = CResult_NonePaymentErrorZ_ok();
22002         return tag_ptr(ret_conv, true);
22003 }
22004
22005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22006         void* e_ptr = untag_ptr(e);
22007         CHECK_ACCESS(e_ptr);
22008         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22009         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22010         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22011         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
22012         return tag_ptr(ret_conv, true);
22013 }
22014
22015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22016         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
22017         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
22018         return ret_conv;
22019 }
22020
22021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22022         if (!ptr_is_owned(_res)) return;
22023         void* _res_ptr = untag_ptr(_res);
22024         CHECK_ACCESS(_res_ptr);
22025         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
22026         FREE(untag_ptr(_res));
22027         CResult_NonePaymentErrorZ_free(_res_conv);
22028 }
22029
22030 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
22031         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22032         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
22033         return tag_ptr(ret_conv, true);
22034 }
22035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22036         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
22037         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
22038         return ret_conv;
22039 }
22040
22041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22042         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
22043         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22044         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
22045         return tag_ptr(ret_conv, true);
22046 }
22047
22048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
22049         LDKStr o_conv = java_to_owned_str(env, o);
22050         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22051         *ret_conv = CResult_StringErrorZ_ok(o_conv);
22052         return tag_ptr(ret_conv, true);
22053 }
22054
22055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22056         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22057         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22058         *ret_conv = CResult_StringErrorZ_err(e_conv);
22059         return tag_ptr(ret_conv, true);
22060 }
22061
22062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22063         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
22064         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
22065         return ret_conv;
22066 }
22067
22068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22069         if (!ptr_is_owned(_res)) return;
22070         void* _res_ptr = untag_ptr(_res);
22071         CHECK_ACCESS(_res_ptr);
22072         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
22073         FREE(untag_ptr(_res));
22074         CResult_StringErrorZ_free(_res_conv);
22075 }
22076
22077 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
22078         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22079         *ret_conv = CResult_StringErrorZ_clone(arg);
22080         return tag_ptr(ret_conv, true);
22081 }
22082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22083         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
22084         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
22085         return ret_conv;
22086 }
22087
22088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22089         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
22090         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22091         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
22092         return tag_ptr(ret_conv, true);
22093 }
22094
22095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22096         LDKPublicKey o_ref;
22097         CHECK((*env)->GetArrayLength(env, o) == 33);
22098         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
22099         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22100         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
22101         return tag_ptr(ret_conv, true);
22102 }
22103
22104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22105         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22106         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22107         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
22108         return tag_ptr(ret_conv, true);
22109 }
22110
22111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22112         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
22113         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
22114         return ret_conv;
22115 }
22116
22117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22118         if (!ptr_is_owned(_res)) return;
22119         void* _res_ptr = untag_ptr(_res);
22120         CHECK_ACCESS(_res_ptr);
22121         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
22122         FREE(untag_ptr(_res));
22123         CResult_PublicKeyErrorZ_free(_res_conv);
22124 }
22125
22126 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
22127         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22128         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
22129         return tag_ptr(ret_conv, true);
22130 }
22131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22132         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
22133         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
22134         return ret_conv;
22135 }
22136
22137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22138         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
22139         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22140         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
22141         return tag_ptr(ret_conv, true);
22142 }
22143
22144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22145         LDKChannelMonitorUpdate o_conv;
22146         o_conv.inner = untag_ptr(o);
22147         o_conv.is_owned = ptr_is_owned(o);
22148         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22149         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22150         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22151         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22152         return tag_ptr(ret_conv, true);
22153 }
22154
22155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22156         void* e_ptr = untag_ptr(e);
22157         CHECK_ACCESS(e_ptr);
22158         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22159         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22160         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22161         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22162         return tag_ptr(ret_conv, true);
22163 }
22164
22165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22166         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22167         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22168         return ret_conv;
22169 }
22170
22171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22172         if (!ptr_is_owned(_res)) return;
22173         void* _res_ptr = untag_ptr(_res);
22174         CHECK_ACCESS(_res_ptr);
22175         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22176         FREE(untag_ptr(_res));
22177         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22178 }
22179
22180 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
22181         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22182         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22183         return tag_ptr(ret_conv, true);
22184 }
22185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22186         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22187         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22188         return ret_conv;
22189 }
22190
22191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22192         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22193         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22194         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22195         return tag_ptr(ret_conv, true);
22196 }
22197
22198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22199         void* o_ptr = untag_ptr(o);
22200         CHECK_ACCESS(o_ptr);
22201         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
22202         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
22203         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22204         *ret_copy = COption_MonitorEventZ_some(o_conv);
22205         int64_t ret_ref = tag_ptr(ret_copy, true);
22206         return ret_ref;
22207 }
22208
22209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
22210         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22211         *ret_copy = COption_MonitorEventZ_none();
22212         int64_t ret_ref = tag_ptr(ret_copy, true);
22213         return ret_ref;
22214 }
22215
22216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22217         if (!ptr_is_owned(_res)) return;
22218         void* _res_ptr = untag_ptr(_res);
22219         CHECK_ACCESS(_res_ptr);
22220         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
22221         FREE(untag_ptr(_res));
22222         COption_MonitorEventZ_free(_res_conv);
22223 }
22224
22225 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
22226         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22227         *ret_copy = COption_MonitorEventZ_clone(arg);
22228         int64_t ret_ref = tag_ptr(ret_copy, true);
22229         return ret_ref;
22230 }
22231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22232         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
22233         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
22234         return ret_conv;
22235 }
22236
22237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22238         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
22239         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22240         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
22241         int64_t ret_ref = tag_ptr(ret_copy, true);
22242         return ret_ref;
22243 }
22244
22245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22246         void* o_ptr = untag_ptr(o);
22247         CHECK_ACCESS(o_ptr);
22248         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
22249         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
22250         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22251         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
22252         return tag_ptr(ret_conv, true);
22253 }
22254
22255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22256         void* e_ptr = untag_ptr(e);
22257         CHECK_ACCESS(e_ptr);
22258         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22259         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22260         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22261         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
22262         return tag_ptr(ret_conv, true);
22263 }
22264
22265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22266         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
22267         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
22268         return ret_conv;
22269 }
22270
22271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22272         if (!ptr_is_owned(_res)) return;
22273         void* _res_ptr = untag_ptr(_res);
22274         CHECK_ACCESS(_res_ptr);
22275         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
22276         FREE(untag_ptr(_res));
22277         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
22278 }
22279
22280 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
22281         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22282         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
22283         return tag_ptr(ret_conv, true);
22284 }
22285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22286         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
22287         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
22288         return ret_conv;
22289 }
22290
22291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22292         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
22293         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22294         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
22295         return tag_ptr(ret_conv, true);
22296 }
22297
22298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22299         LDKHTLCUpdate o_conv;
22300         o_conv.inner = untag_ptr(o);
22301         o_conv.is_owned = ptr_is_owned(o);
22302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22303         o_conv = HTLCUpdate_clone(&o_conv);
22304         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22305         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
22306         return tag_ptr(ret_conv, true);
22307 }
22308
22309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22310         void* e_ptr = untag_ptr(e);
22311         CHECK_ACCESS(e_ptr);
22312         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22313         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22314         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22315         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
22316         return tag_ptr(ret_conv, true);
22317 }
22318
22319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22320         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
22321         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
22322         return ret_conv;
22323 }
22324
22325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22326         if (!ptr_is_owned(_res)) return;
22327         void* _res_ptr = untag_ptr(_res);
22328         CHECK_ACCESS(_res_ptr);
22329         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
22330         FREE(untag_ptr(_res));
22331         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
22332 }
22333
22334 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
22335         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22336         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
22337         return tag_ptr(ret_conv, true);
22338 }
22339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22340         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
22341         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
22342         return ret_conv;
22343 }
22344
22345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22346         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
22347         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22348         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
22349         return tag_ptr(ret_conv, true);
22350 }
22351
22352 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
22353         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22354         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
22355         return tag_ptr(ret_conv, true);
22356 }
22357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22358         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
22359         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
22360         return ret_conv;
22361 }
22362
22363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22364         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
22365         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22366         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
22367         return tag_ptr(ret_conv, true);
22368 }
22369
22370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
22371         LDKOutPoint a_conv;
22372         a_conv.inner = untag_ptr(a);
22373         a_conv.is_owned = ptr_is_owned(a);
22374         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22375         a_conv = OutPoint_clone(&a_conv);
22376         LDKCVec_u8Z b_ref;
22377         b_ref.datalen = (*env)->GetArrayLength(env, b);
22378         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22379         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22380         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22381         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
22382         return tag_ptr(ret_conv, true);
22383 }
22384
22385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22386         if (!ptr_is_owned(_res)) return;
22387         void* _res_ptr = untag_ptr(_res);
22388         CHECK_ACCESS(_res_ptr);
22389         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
22390         FREE(untag_ptr(_res));
22391         C2Tuple_OutPointScriptZ_free(_res_conv);
22392 }
22393
22394 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
22395         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22396         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
22397         return tag_ptr(ret_conv, true);
22398 }
22399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22400         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
22401         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
22402         return ret_conv;
22403 }
22404
22405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22406         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
22407         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22408         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
22409         return tag_ptr(ret_conv, true);
22410 }
22411
22412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
22413         LDKCVec_u8Z b_ref;
22414         b_ref.datalen = (*env)->GetArrayLength(env, b);
22415         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22416         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22417         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22418         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
22419         return tag_ptr(ret_conv, true);
22420 }
22421
22422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22423         if (!ptr_is_owned(_res)) return;
22424         void* _res_ptr = untag_ptr(_res);
22425         CHECK_ACCESS(_res_ptr);
22426         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
22427         FREE(untag_ptr(_res));
22428         C2Tuple_u32ScriptZ_free(_res_conv);
22429 }
22430
22431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22432         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
22433         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22434         if (_res_constr.datalen > 0)
22435                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22436         else
22437                 _res_constr.data = NULL;
22438         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22439         for (size_t v = 0; v < _res_constr.datalen; v++) {
22440                 int64_t _res_conv_21 = _res_vals[v];
22441                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
22442                 CHECK_ACCESS(_res_conv_21_ptr);
22443                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
22444                 FREE(untag_ptr(_res_conv_21));
22445                 _res_constr.data[v] = _res_conv_21_conv;
22446         }
22447         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22448         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
22449 }
22450
22451 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
22452         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22453         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
22454         return tag_ptr(ret_conv, true);
22455 }
22456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22457         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
22458         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
22459         return ret_conv;
22460 }
22461
22462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22463         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
22464         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22465         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
22466         return tag_ptr(ret_conv, true);
22467 }
22468
22469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22470         LDKThirtyTwoBytes a_ref;
22471         CHECK((*env)->GetArrayLength(env, a) == 32);
22472         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22473         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
22474         b_constr.datalen = (*env)->GetArrayLength(env, b);
22475         if (b_constr.datalen > 0)
22476                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22477         else
22478                 b_constr.data = NULL;
22479         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22480         for (size_t v = 0; v < b_constr.datalen; v++) {
22481                 int64_t b_conv_21 = b_vals[v];
22482                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
22483                 CHECK_ACCESS(b_conv_21_ptr);
22484                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
22485                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
22486                 b_constr.data[v] = b_conv_21_conv;
22487         }
22488         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22489         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22490         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
22491         return tag_ptr(ret_conv, true);
22492 }
22493
22494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22495         if (!ptr_is_owned(_res)) return;
22496         void* _res_ptr = untag_ptr(_res);
22497         CHECK_ACCESS(_res_ptr);
22498         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
22499         FREE(untag_ptr(_res));
22500         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
22501 }
22502
22503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22504         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
22505         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22506         if (_res_constr.datalen > 0)
22507                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
22508         else
22509                 _res_constr.data = NULL;
22510         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22511         for (size_t o = 0; o < _res_constr.datalen; o++) {
22512                 int64_t _res_conv_40 = _res_vals[o];
22513                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
22514                 CHECK_ACCESS(_res_conv_40_ptr);
22515                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
22516                 FREE(untag_ptr(_res_conv_40));
22517                 _res_constr.data[o] = _res_conv_40_conv;
22518         }
22519         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22520         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
22521 }
22522
22523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22524         LDKCVec_EventZ _res_constr;
22525         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22526         if (_res_constr.datalen > 0)
22527                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
22528         else
22529                 _res_constr.data = NULL;
22530         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22531         for (size_t h = 0; h < _res_constr.datalen; h++) {
22532                 int64_t _res_conv_7 = _res_vals[h];
22533                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
22534                 CHECK_ACCESS(_res_conv_7_ptr);
22535                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
22536                 FREE(untag_ptr(_res_conv_7));
22537                 _res_constr.data[h] = _res_conv_7_conv;
22538         }
22539         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22540         CVec_EventZ_free(_res_constr);
22541 }
22542
22543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
22544         LDKCVec_TransactionZ _res_constr;
22545         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22546         if (_res_constr.datalen > 0)
22547                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22548         else
22549                 _res_constr.data = NULL;
22550         for (size_t i = 0; i < _res_constr.datalen; i++) {
22551                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
22552                 LDKTransaction _res_conv_8_ref;
22553                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
22554                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22555                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
22556                 _res_conv_8_ref.data_is_owned = true;
22557                 _res_constr.data[i] = _res_conv_8_ref;
22558         }
22559         CVec_TransactionZ_free(_res_constr);
22560 }
22561
22562 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22563         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22564         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22565         return tag_ptr(ret_conv, true);
22566 }
22567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22568         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22569         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22570         return ret_conv;
22571 }
22572
22573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22574         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22575         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22576         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22577         return tag_ptr(ret_conv, true);
22578 }
22579
22580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
22581         void* b_ptr = untag_ptr(b);
22582         CHECK_ACCESS(b_ptr);
22583         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22584         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22585         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22586         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22587         return tag_ptr(ret_conv, true);
22588 }
22589
22590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22591         if (!ptr_is_owned(_res)) return;
22592         void* _res_ptr = untag_ptr(_res);
22593         CHECK_ACCESS(_res_ptr);
22594         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22595         FREE(untag_ptr(_res));
22596         C2Tuple_u32TxOutZ_free(_res_conv);
22597 }
22598
22599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22600         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22601         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22602         if (_res_constr.datalen > 0)
22603                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22604         else
22605                 _res_constr.data = NULL;
22606         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22607         for (size_t u = 0; u < _res_constr.datalen; u++) {
22608                 int64_t _res_conv_20 = _res_vals[u];
22609                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22610                 CHECK_ACCESS(_res_conv_20_ptr);
22611                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22612                 FREE(untag_ptr(_res_conv_20));
22613                 _res_constr.data[u] = _res_conv_20_conv;
22614         }
22615         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22616         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22617 }
22618
22619 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22620         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22621         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22622         return tag_ptr(ret_conv, true);
22623 }
22624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22625         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22626         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22627         return ret_conv;
22628 }
22629
22630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22631         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22632         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22633         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22634         return tag_ptr(ret_conv, true);
22635 }
22636
22637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22638         LDKThirtyTwoBytes a_ref;
22639         CHECK((*env)->GetArrayLength(env, a) == 32);
22640         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22641         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22642         b_constr.datalen = (*env)->GetArrayLength(env, b);
22643         if (b_constr.datalen > 0)
22644                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22645         else
22646                 b_constr.data = NULL;
22647         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22648         for (size_t u = 0; u < b_constr.datalen; u++) {
22649                 int64_t b_conv_20 = b_vals[u];
22650                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22651                 CHECK_ACCESS(b_conv_20_ptr);
22652                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22653                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22654                 b_constr.data[u] = b_conv_20_conv;
22655         }
22656         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22657         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22658         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22659         return tag_ptr(ret_conv, true);
22660 }
22661
22662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22663         if (!ptr_is_owned(_res)) return;
22664         void* _res_ptr = untag_ptr(_res);
22665         CHECK_ACCESS(_res_ptr);
22666         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22667         FREE(untag_ptr(_res));
22668         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22669 }
22670
22671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22672         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22673         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22674         if (_res_constr.datalen > 0)
22675                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
22676         else
22677                 _res_constr.data = NULL;
22678         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22679         for (size_t n = 0; n < _res_constr.datalen; n++) {
22680                 int64_t _res_conv_39 = _res_vals[n];
22681                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
22682                 CHECK_ACCESS(_res_conv_39_ptr);
22683                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
22684                 FREE(untag_ptr(_res_conv_39));
22685                 _res_constr.data[n] = _res_conv_39_conv;
22686         }
22687         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22688         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22689 }
22690
22691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22692         LDKCVec_BalanceZ _res_constr;
22693         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22694         if (_res_constr.datalen > 0)
22695                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22696         else
22697                 _res_constr.data = NULL;
22698         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22699         for (size_t j = 0; j < _res_constr.datalen; j++) {
22700                 int64_t _res_conv_9 = _res_vals[j];
22701                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22702                 CHECK_ACCESS(_res_conv_9_ptr);
22703                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22704                 FREE(untag_ptr(_res_conv_9));
22705                 _res_constr.data[j] = _res_conv_9_conv;
22706         }
22707         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22708         CVec_BalanceZ_free(_res_constr);
22709 }
22710
22711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22712         void* o_ptr = untag_ptr(o);
22713         CHECK_ACCESS(o_ptr);
22714         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
22715         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
22716         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22717         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
22718         return tag_ptr(ret_conv, true);
22719 }
22720
22721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22722         void* e_ptr = untag_ptr(e);
22723         CHECK_ACCESS(e_ptr);
22724         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22725         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22726         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22727         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
22728         return tag_ptr(ret_conv, true);
22729 }
22730
22731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22732         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22733         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22734         return ret_conv;
22735 }
22736
22737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22738         if (!ptr_is_owned(_res)) return;
22739         void* _res_ptr = untag_ptr(_res);
22740         CHECK_ACCESS(_res_ptr);
22741         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
22742         FREE(untag_ptr(_res));
22743         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
22744 }
22745
22746 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22747         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22748         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
22749         return tag_ptr(ret_conv, true);
22750 }
22751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22752         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22753         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22754         return ret_conv;
22755 }
22756
22757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22758         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22759         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22760         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
22761         return tag_ptr(ret_conv, true);
22762 }
22763
22764 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22765         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22766         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22767         return tag_ptr(ret_conv, true);
22768 }
22769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22770         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22771         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22772         return ret_conv;
22773 }
22774
22775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22776         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22777         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22778         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22779         return tag_ptr(ret_conv, true);
22780 }
22781
22782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22783         LDKPublicKey a_ref;
22784         CHECK((*env)->GetArrayLength(env, a) == 33);
22785         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
22786         void* b_ptr = untag_ptr(b);
22787         CHECK_ACCESS(b_ptr);
22788         LDKType b_conv = *(LDKType*)(b_ptr);
22789         if (b_conv.free == LDKType_JCalls_free) {
22790                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22791                 LDKType_JCalls_cloned(&b_conv);
22792         }
22793         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22794         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22795         return tag_ptr(ret_conv, true);
22796 }
22797
22798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22799         if (!ptr_is_owned(_res)) return;
22800         void* _res_ptr = untag_ptr(_res);
22801         CHECK_ACCESS(_res_ptr);
22802         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22803         FREE(untag_ptr(_res));
22804         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22805 }
22806
22807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22808         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22809         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22810         if (_res_constr.datalen > 0)
22811                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22812         else
22813                 _res_constr.data = NULL;
22814         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22815         for (size_t z = 0; z < _res_constr.datalen; z++) {
22816                 int64_t _res_conv_25 = _res_vals[z];
22817                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22818                 CHECK_ACCESS(_res_conv_25_ptr);
22819                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22820                 FREE(untag_ptr(_res_conv_25));
22821                 _res_constr.data[z] = _res_conv_25_conv;
22822         }
22823         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22824         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22825 }
22826
22827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22828         void* o_ptr = untag_ptr(o);
22829         CHECK_ACCESS(o_ptr);
22830         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
22831         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
22832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22833                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
22834         }
22835         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22836         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
22837         int64_t ret_ref = tag_ptr(ret_copy, true);
22838         return ret_ref;
22839 }
22840
22841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
22842         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22843         *ret_copy = COption_CustomOnionMessageContentsZ_none();
22844         int64_t ret_ref = tag_ptr(ret_copy, true);
22845         return ret_ref;
22846 }
22847
22848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22849         if (!ptr_is_owned(_res)) return;
22850         void* _res_ptr = untag_ptr(_res);
22851         CHECK_ACCESS(_res_ptr);
22852         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
22853         FREE(untag_ptr(_res));
22854         COption_CustomOnionMessageContentsZ_free(_res_conv);
22855 }
22856
22857 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
22858         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22859         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
22860         int64_t ret_ref = tag_ptr(ret_copy, true);
22861         return ret_ref;
22862 }
22863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22864         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
22865         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
22866         return ret_conv;
22867 }
22868
22869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22870         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
22871         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22872         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
22873         int64_t ret_ref = tag_ptr(ret_copy, true);
22874         return ret_ref;
22875 }
22876
22877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22878         void* o_ptr = untag_ptr(o);
22879         CHECK_ACCESS(o_ptr);
22880         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
22881         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
22882         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22883         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
22884         return tag_ptr(ret_conv, true);
22885 }
22886
22887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22888         void* e_ptr = untag_ptr(e);
22889         CHECK_ACCESS(e_ptr);
22890         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22891         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22892         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22893         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
22894         return tag_ptr(ret_conv, true);
22895 }
22896
22897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22898         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
22899         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
22900         return ret_conv;
22901 }
22902
22903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22904         if (!ptr_is_owned(_res)) return;
22905         void* _res_ptr = untag_ptr(_res);
22906         CHECK_ACCESS(_res_ptr);
22907         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
22908         FREE(untag_ptr(_res));
22909         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
22910 }
22911
22912 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
22913         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22914         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
22915         return tag_ptr(ret_conv, true);
22916 }
22917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22918         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
22919         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
22920         return ret_conv;
22921 }
22922
22923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22924         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
22925         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22926         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
22927         return tag_ptr(ret_conv, true);
22928 }
22929
22930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22931         void* o_ptr = untag_ptr(o);
22932         CHECK_ACCESS(o_ptr);
22933         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22934         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
22935         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22936         *ret_copy = COption_NetAddressZ_some(o_conv);
22937         int64_t ret_ref = tag_ptr(ret_copy, true);
22938         return ret_ref;
22939 }
22940
22941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
22942         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22943         *ret_copy = COption_NetAddressZ_none();
22944         int64_t ret_ref = tag_ptr(ret_copy, true);
22945         return ret_ref;
22946 }
22947
22948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22949         if (!ptr_is_owned(_res)) return;
22950         void* _res_ptr = untag_ptr(_res);
22951         CHECK_ACCESS(_res_ptr);
22952         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
22953         FREE(untag_ptr(_res));
22954         COption_NetAddressZ_free(_res_conv);
22955 }
22956
22957 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
22958         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22959         *ret_copy = COption_NetAddressZ_clone(arg);
22960         int64_t ret_ref = tag_ptr(ret_copy, true);
22961         return ret_ref;
22962 }
22963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22964         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
22965         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
22966         return ret_conv;
22967 }
22968
22969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22970         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
22971         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22972         *ret_copy = COption_NetAddressZ_clone(orig_conv);
22973         int64_t ret_ref = tag_ptr(ret_copy, true);
22974         return ret_ref;
22975 }
22976
22977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22978         LDKCVec_u8Z o_ref;
22979         o_ref.datalen = (*env)->GetArrayLength(env, o);
22980         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
22981         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
22982         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22983         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
22984         return tag_ptr(ret_conv, true);
22985 }
22986
22987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22988         LDKPeerHandleError e_conv;
22989         e_conv.inner = untag_ptr(e);
22990         e_conv.is_owned = ptr_is_owned(e);
22991         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22992         e_conv = PeerHandleError_clone(&e_conv);
22993         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22994         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22995         return tag_ptr(ret_conv, true);
22996 }
22997
22998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22999         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23000         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23001         return ret_conv;
23002 }
23003
23004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23005         if (!ptr_is_owned(_res)) return;
23006         void* _res_ptr = untag_ptr(_res);
23007         CHECK_ACCESS(_res_ptr);
23008         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23009         FREE(untag_ptr(_res));
23010         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23011 }
23012
23013 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23014         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23015         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23016         return tag_ptr(ret_conv, true);
23017 }
23018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23019         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23020         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23021         return ret_conv;
23022 }
23023
23024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23025         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23026         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23027         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23028         return tag_ptr(ret_conv, true);
23029 }
23030
23031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
23032         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23033         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23034         return tag_ptr(ret_conv, true);
23035 }
23036
23037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23038         LDKPeerHandleError e_conv;
23039         e_conv.inner = untag_ptr(e);
23040         e_conv.is_owned = ptr_is_owned(e);
23041         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23042         e_conv = PeerHandleError_clone(&e_conv);
23043         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23044         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23045         return tag_ptr(ret_conv, true);
23046 }
23047
23048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23049         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23050         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23051         return ret_conv;
23052 }
23053
23054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23055         if (!ptr_is_owned(_res)) return;
23056         void* _res_ptr = untag_ptr(_res);
23057         CHECK_ACCESS(_res_ptr);
23058         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23059         FREE(untag_ptr(_res));
23060         CResult_NonePeerHandleErrorZ_free(_res_conv);
23061 }
23062
23063 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23064         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23065         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23066         return tag_ptr(ret_conv, true);
23067 }
23068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23069         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23070         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23071         return ret_conv;
23072 }
23073
23074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23075         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23076         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23077         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23078         return tag_ptr(ret_conv, true);
23079 }
23080
23081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
23082         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23083         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23084         return tag_ptr(ret_conv, true);
23085 }
23086
23087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23088         LDKPeerHandleError e_conv;
23089         e_conv.inner = untag_ptr(e);
23090         e_conv.is_owned = ptr_is_owned(e);
23091         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23092         e_conv = PeerHandleError_clone(&e_conv);
23093         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23094         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23095         return tag_ptr(ret_conv, true);
23096 }
23097
23098 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23099         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23100         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23101         return ret_conv;
23102 }
23103
23104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23105         if (!ptr_is_owned(_res)) return;
23106         void* _res_ptr = untag_ptr(_res);
23107         CHECK_ACCESS(_res_ptr);
23108         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23109         FREE(untag_ptr(_res));
23110         CResult_boolPeerHandleErrorZ_free(_res_conv);
23111 }
23112
23113 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23114         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23115         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23116         return tag_ptr(ret_conv, true);
23117 }
23118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23119         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
23120         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
23121         return ret_conv;
23122 }
23123
23124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23125         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
23126         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23127         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
23128         return tag_ptr(ret_conv, true);
23129 }
23130
23131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
23132         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
23133         *ret_conv = CResult_NoneSendErrorZ_ok();
23134         return tag_ptr(ret_conv, true);
23135 }
23136
23137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23138         void* e_ptr = untag_ptr(e);
23139         CHECK_ACCESS(e_ptr);
23140         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
23141         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
23142         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
23143         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
23144         return tag_ptr(ret_conv, true);
23145 }
23146
23147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23148         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
23149         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
23150         return ret_conv;
23151 }
23152
23153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23154         if (!ptr_is_owned(_res)) return;
23155         void* _res_ptr = untag_ptr(_res);
23156         CHECK_ACCESS(_res_ptr);
23157         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
23158         FREE(untag_ptr(_res));
23159         CResult_NoneSendErrorZ_free(_res_conv);
23160 }
23161
23162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
23163         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
23164         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23165         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
23166         return tag_ptr(ret_conv, true);
23167 }
23168
23169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23170         void* e_ptr = untag_ptr(e);
23171         CHECK_ACCESS(e_ptr);
23172         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
23173         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
23174         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23175         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
23176         return tag_ptr(ret_conv, true);
23177 }
23178
23179 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23180         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
23181         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
23182         return ret_conv;
23183 }
23184
23185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23186         if (!ptr_is_owned(_res)) return;
23187         void* _res_ptr = untag_ptr(_res);
23188         CHECK_ACCESS(_res_ptr);
23189         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
23190         FREE(untag_ptr(_res));
23191         CResult_SiPrefixParseErrorZ_free(_res_conv);
23192 }
23193
23194 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
23195         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23196         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
23197         return tag_ptr(ret_conv, true);
23198 }
23199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23200         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
23201         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
23202         return ret_conv;
23203 }
23204
23205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23206         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
23207         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23208         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
23209         return tag_ptr(ret_conv, true);
23210 }
23211
23212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23213         LDKInvoice o_conv;
23214         o_conv.inner = untag_ptr(o);
23215         o_conv.is_owned = ptr_is_owned(o);
23216         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23217         o_conv = Invoice_clone(&o_conv);
23218         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23219         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
23220         return tag_ptr(ret_conv, true);
23221 }
23222
23223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23224         void* e_ptr = untag_ptr(e);
23225         CHECK_ACCESS(e_ptr);
23226         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
23227         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
23228         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23229         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
23230         return tag_ptr(ret_conv, true);
23231 }
23232
23233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23234         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
23235         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
23236         return ret_conv;
23237 }
23238
23239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23240         if (!ptr_is_owned(_res)) return;
23241         void* _res_ptr = untag_ptr(_res);
23242         CHECK_ACCESS(_res_ptr);
23243         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
23244         FREE(untag_ptr(_res));
23245         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
23246 }
23247
23248 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
23249         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23250         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
23251         return tag_ptr(ret_conv, true);
23252 }
23253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23254         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
23255         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
23256         return ret_conv;
23257 }
23258
23259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23260         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
23261         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23262         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
23263         return tag_ptr(ret_conv, true);
23264 }
23265
23266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23267         LDKSignedRawInvoice o_conv;
23268         o_conv.inner = untag_ptr(o);
23269         o_conv.is_owned = ptr_is_owned(o);
23270         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23271         o_conv = SignedRawInvoice_clone(&o_conv);
23272         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23273         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
23274         return tag_ptr(ret_conv, true);
23275 }
23276
23277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23278         void* e_ptr = untag_ptr(e);
23279         CHECK_ACCESS(e_ptr);
23280         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
23281         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
23282         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23283         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
23284         return tag_ptr(ret_conv, true);
23285 }
23286
23287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23288         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
23289         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
23290         return ret_conv;
23291 }
23292
23293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23294         if (!ptr_is_owned(_res)) return;
23295         void* _res_ptr = untag_ptr(_res);
23296         CHECK_ACCESS(_res_ptr);
23297         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
23298         FREE(untag_ptr(_res));
23299         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
23300 }
23301
23302 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
23303         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23304         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
23305         return tag_ptr(ret_conv, true);
23306 }
23307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23308         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
23309         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
23310         return ret_conv;
23311 }
23312
23313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23314         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
23315         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23316         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
23317         return tag_ptr(ret_conv, true);
23318 }
23319
23320 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
23321         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23322         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
23323         return tag_ptr(ret_conv, true);
23324 }
23325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23326         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
23327         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
23328         return ret_conv;
23329 }
23330
23331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23332         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
23333         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23334         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
23335         return tag_ptr(ret_conv, true);
23336 }
23337
23338 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) {
23339         LDKRawInvoice a_conv;
23340         a_conv.inner = untag_ptr(a);
23341         a_conv.is_owned = ptr_is_owned(a);
23342         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23343         a_conv = RawInvoice_clone(&a_conv);
23344         LDKThirtyTwoBytes b_ref;
23345         CHECK((*env)->GetArrayLength(env, b) == 32);
23346         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
23347         LDKInvoiceSignature c_conv;
23348         c_conv.inner = untag_ptr(c);
23349         c_conv.is_owned = ptr_is_owned(c);
23350         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
23351         c_conv = InvoiceSignature_clone(&c_conv);
23352         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23353         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
23354         return tag_ptr(ret_conv, true);
23355 }
23356
23357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23358         if (!ptr_is_owned(_res)) return;
23359         void* _res_ptr = untag_ptr(_res);
23360         CHECK_ACCESS(_res_ptr);
23361         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
23362         FREE(untag_ptr(_res));
23363         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
23364 }
23365
23366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23367         LDKPayeePubKey o_conv;
23368         o_conv.inner = untag_ptr(o);
23369         o_conv.is_owned = ptr_is_owned(o);
23370         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23371         o_conv = PayeePubKey_clone(&o_conv);
23372         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23373         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
23374         return tag_ptr(ret_conv, true);
23375 }
23376
23377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23378         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
23379         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23380         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
23381         return tag_ptr(ret_conv, true);
23382 }
23383
23384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23385         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
23386         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
23387         return ret_conv;
23388 }
23389
23390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23391         if (!ptr_is_owned(_res)) return;
23392         void* _res_ptr = untag_ptr(_res);
23393         CHECK_ACCESS(_res_ptr);
23394         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
23395         FREE(untag_ptr(_res));
23396         CResult_PayeePubKeyErrorZ_free(_res_conv);
23397 }
23398
23399 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
23400         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23401         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
23402         return tag_ptr(ret_conv, true);
23403 }
23404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23405         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
23406         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
23407         return ret_conv;
23408 }
23409
23410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23411         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
23412         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23413         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
23414         return tag_ptr(ret_conv, true);
23415 }
23416
23417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23418         LDKCVec_PrivateRouteZ _res_constr;
23419         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23420         if (_res_constr.datalen > 0)
23421                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
23422         else
23423                 _res_constr.data = NULL;
23424         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23425         for (size_t o = 0; o < _res_constr.datalen; o++) {
23426                 int64_t _res_conv_14 = _res_vals[o];
23427                 LDKPrivateRoute _res_conv_14_conv;
23428                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
23429                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
23430                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
23431                 _res_constr.data[o] = _res_conv_14_conv;
23432         }
23433         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23434         CVec_PrivateRouteZ_free(_res_constr);
23435 }
23436
23437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23438         LDKPositiveTimestamp o_conv;
23439         o_conv.inner = untag_ptr(o);
23440         o_conv.is_owned = ptr_is_owned(o);
23441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23442         o_conv = PositiveTimestamp_clone(&o_conv);
23443         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23444         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
23445         return tag_ptr(ret_conv, true);
23446 }
23447
23448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23449         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23450         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23451         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
23452         return tag_ptr(ret_conv, true);
23453 }
23454
23455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23456         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
23457         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
23458         return ret_conv;
23459 }
23460
23461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23462         if (!ptr_is_owned(_res)) return;
23463         void* _res_ptr = untag_ptr(_res);
23464         CHECK_ACCESS(_res_ptr);
23465         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
23466         FREE(untag_ptr(_res));
23467         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
23468 }
23469
23470 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
23471         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23472         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
23473         return tag_ptr(ret_conv, true);
23474 }
23475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23476         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
23477         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
23478         return ret_conv;
23479 }
23480
23481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23482         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
23483         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23484         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
23485         return tag_ptr(ret_conv, true);
23486 }
23487
23488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
23489         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23490         *ret_conv = CResult_NoneSemanticErrorZ_ok();
23491         return tag_ptr(ret_conv, true);
23492 }
23493
23494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23495         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
23496         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23497         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
23498         return tag_ptr(ret_conv, true);
23499 }
23500
23501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23502         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
23503         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
23504         return ret_conv;
23505 }
23506
23507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23508         if (!ptr_is_owned(_res)) return;
23509         void* _res_ptr = untag_ptr(_res);
23510         CHECK_ACCESS(_res_ptr);
23511         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
23512         FREE(untag_ptr(_res));
23513         CResult_NoneSemanticErrorZ_free(_res_conv);
23514 }
23515
23516 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
23517         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23518         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
23519         return tag_ptr(ret_conv, true);
23520 }
23521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23522         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
23523         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
23524         return ret_conv;
23525 }
23526
23527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23528         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
23529         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23530         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
23531         return tag_ptr(ret_conv, true);
23532 }
23533
23534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23535         LDKInvoice o_conv;
23536         o_conv.inner = untag_ptr(o);
23537         o_conv.is_owned = ptr_is_owned(o);
23538         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23539         o_conv = Invoice_clone(&o_conv);
23540         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23541         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
23542         return tag_ptr(ret_conv, true);
23543 }
23544
23545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23546         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
23547         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23548         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
23549         return tag_ptr(ret_conv, true);
23550 }
23551
23552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23553         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
23554         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
23555         return ret_conv;
23556 }
23557
23558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23559         if (!ptr_is_owned(_res)) return;
23560         void* _res_ptr = untag_ptr(_res);
23561         CHECK_ACCESS(_res_ptr);
23562         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
23563         FREE(untag_ptr(_res));
23564         CResult_InvoiceSemanticErrorZ_free(_res_conv);
23565 }
23566
23567 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
23568         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23569         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
23570         return tag_ptr(ret_conv, true);
23571 }
23572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23573         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
23574         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
23575         return ret_conv;
23576 }
23577
23578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23579         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
23580         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23581         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
23582         return tag_ptr(ret_conv, true);
23583 }
23584
23585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23586         LDKDescription o_conv;
23587         o_conv.inner = untag_ptr(o);
23588         o_conv.is_owned = ptr_is_owned(o);
23589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23590         o_conv = Description_clone(&o_conv);
23591         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23592         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
23593         return tag_ptr(ret_conv, true);
23594 }
23595
23596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23597         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23598         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23599         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
23600         return tag_ptr(ret_conv, true);
23601 }
23602
23603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23604         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
23605         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
23606         return ret_conv;
23607 }
23608
23609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23610         if (!ptr_is_owned(_res)) return;
23611         void* _res_ptr = untag_ptr(_res);
23612         CHECK_ACCESS(_res_ptr);
23613         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
23614         FREE(untag_ptr(_res));
23615         CResult_DescriptionCreationErrorZ_free(_res_conv);
23616 }
23617
23618 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
23619         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23620         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
23621         return tag_ptr(ret_conv, true);
23622 }
23623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23624         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
23625         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
23626         return ret_conv;
23627 }
23628
23629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23630         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
23631         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23632         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
23633         return tag_ptr(ret_conv, true);
23634 }
23635
23636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23637         LDKPrivateRoute o_conv;
23638         o_conv.inner = untag_ptr(o);
23639         o_conv.is_owned = ptr_is_owned(o);
23640         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23641         o_conv = PrivateRoute_clone(&o_conv);
23642         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23643         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
23644         return tag_ptr(ret_conv, true);
23645 }
23646
23647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23648         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23649         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23650         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
23651         return tag_ptr(ret_conv, true);
23652 }
23653
23654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23655         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
23656         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
23657         return ret_conv;
23658 }
23659
23660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23661         if (!ptr_is_owned(_res)) return;
23662         void* _res_ptr = untag_ptr(_res);
23663         CHECK_ACCESS(_res_ptr);
23664         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
23665         FREE(untag_ptr(_res));
23666         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
23667 }
23668
23669 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
23670         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23671         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
23672         return tag_ptr(ret_conv, true);
23673 }
23674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23675         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
23676         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
23677         return ret_conv;
23678 }
23679
23680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23681         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
23682         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23683         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
23684         return tag_ptr(ret_conv, true);
23685 }
23686
23687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
23688         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23689         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
23690         return tag_ptr(ret_conv, true);
23691 }
23692
23693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23694         void* e_ptr = untag_ptr(e);
23695         CHECK_ACCESS(e_ptr);
23696         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
23697         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
23698         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23699         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
23700         return tag_ptr(ret_conv, true);
23701 }
23702
23703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23704         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
23705         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
23706         return ret_conv;
23707 }
23708
23709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23710         if (!ptr_is_owned(_res)) return;
23711         void* _res_ptr = untag_ptr(_res);
23712         CHECK_ACCESS(_res_ptr);
23713         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
23714         FREE(untag_ptr(_res));
23715         CResult_u32GraphSyncErrorZ_free(_res_conv);
23716 }
23717
23718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23719         void* o_ptr = untag_ptr(o);
23720         CHECK_ACCESS(o_ptr);
23721         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23722         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23723         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23724         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
23725         return tag_ptr(ret_conv, true);
23726 }
23727
23728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23729         void* e_ptr = untag_ptr(e);
23730         CHECK_ACCESS(e_ptr);
23731         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23732         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23733         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23734         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
23735         return tag_ptr(ret_conv, true);
23736 }
23737
23738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23739         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
23740         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
23741         return ret_conv;
23742 }
23743
23744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23745         if (!ptr_is_owned(_res)) return;
23746         void* _res_ptr = untag_ptr(_res);
23747         CHECK_ACCESS(_res_ptr);
23748         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
23749         FREE(untag_ptr(_res));
23750         CResult_NetAddressDecodeErrorZ_free(_res_conv);
23751 }
23752
23753 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
23754         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23755         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
23756         return tag_ptr(ret_conv, true);
23757 }
23758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23759         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
23760         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
23761         return ret_conv;
23762 }
23763
23764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23765         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
23766         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23767         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
23768         return tag_ptr(ret_conv, true);
23769 }
23770
23771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23772         LDKCVec_UpdateAddHTLCZ _res_constr;
23773         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23774         if (_res_constr.datalen > 0)
23775                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23776         else
23777                 _res_constr.data = NULL;
23778         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23779         for (size_t p = 0; p < _res_constr.datalen; p++) {
23780                 int64_t _res_conv_15 = _res_vals[p];
23781                 LDKUpdateAddHTLC _res_conv_15_conv;
23782                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
23783                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
23784                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
23785                 _res_constr.data[p] = _res_conv_15_conv;
23786         }
23787         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23788         CVec_UpdateAddHTLCZ_free(_res_constr);
23789 }
23790
23791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23792         LDKCVec_UpdateFulfillHTLCZ _res_constr;
23793         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23794         if (_res_constr.datalen > 0)
23795                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23796         else
23797                 _res_constr.data = NULL;
23798         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23799         for (size_t t = 0; t < _res_constr.datalen; t++) {
23800                 int64_t _res_conv_19 = _res_vals[t];
23801                 LDKUpdateFulfillHTLC _res_conv_19_conv;
23802                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
23803                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
23804                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23805                 _res_constr.data[t] = _res_conv_19_conv;
23806         }
23807         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23808         CVec_UpdateFulfillHTLCZ_free(_res_constr);
23809 }
23810
23811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23812         LDKCVec_UpdateFailHTLCZ _res_constr;
23813         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23814         if (_res_constr.datalen > 0)
23815                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23816         else
23817                 _res_constr.data = NULL;
23818         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23819         for (size_t q = 0; q < _res_constr.datalen; q++) {
23820                 int64_t _res_conv_16 = _res_vals[q];
23821                 LDKUpdateFailHTLC _res_conv_16_conv;
23822                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
23823                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
23824                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
23825                 _res_constr.data[q] = _res_conv_16_conv;
23826         }
23827         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23828         CVec_UpdateFailHTLCZ_free(_res_constr);
23829 }
23830
23831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23832         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
23833         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23834         if (_res_constr.datalen > 0)
23835                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23836         else
23837                 _res_constr.data = NULL;
23838         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23839         for (size_t z = 0; z < _res_constr.datalen; z++) {
23840                 int64_t _res_conv_25 = _res_vals[z];
23841                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
23842                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
23843                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
23844                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
23845                 _res_constr.data[z] = _res_conv_25_conv;
23846         }
23847         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23848         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
23849 }
23850
23851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23852         LDKAcceptChannel o_conv;
23853         o_conv.inner = untag_ptr(o);
23854         o_conv.is_owned = ptr_is_owned(o);
23855         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23856         o_conv = AcceptChannel_clone(&o_conv);
23857         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23858         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
23859         return tag_ptr(ret_conv, true);
23860 }
23861
23862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23863         void* e_ptr = untag_ptr(e);
23864         CHECK_ACCESS(e_ptr);
23865         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23866         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23867         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23868         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
23869         return tag_ptr(ret_conv, true);
23870 }
23871
23872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23873         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
23874         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
23875         return ret_conv;
23876 }
23877
23878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23879         if (!ptr_is_owned(_res)) return;
23880         void* _res_ptr = untag_ptr(_res);
23881         CHECK_ACCESS(_res_ptr);
23882         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
23883         FREE(untag_ptr(_res));
23884         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
23885 }
23886
23887 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
23888         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23889         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
23890         return tag_ptr(ret_conv, true);
23891 }
23892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23893         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
23894         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
23895         return ret_conv;
23896 }
23897
23898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23899         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
23900         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23901         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
23902         return tag_ptr(ret_conv, true);
23903 }
23904
23905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23906         LDKAnnouncementSignatures o_conv;
23907         o_conv.inner = untag_ptr(o);
23908         o_conv.is_owned = ptr_is_owned(o);
23909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23910         o_conv = AnnouncementSignatures_clone(&o_conv);
23911         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23912         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
23913         return tag_ptr(ret_conv, true);
23914 }
23915
23916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23917         void* e_ptr = untag_ptr(e);
23918         CHECK_ACCESS(e_ptr);
23919         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23920         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23921         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23922         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
23923         return tag_ptr(ret_conv, true);
23924 }
23925
23926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23927         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
23928         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
23929         return ret_conv;
23930 }
23931
23932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23933         if (!ptr_is_owned(_res)) return;
23934         void* _res_ptr = untag_ptr(_res);
23935         CHECK_ACCESS(_res_ptr);
23936         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
23937         FREE(untag_ptr(_res));
23938         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
23939 }
23940
23941 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
23942         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23943         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
23944         return tag_ptr(ret_conv, true);
23945 }
23946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23947         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
23948         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
23949         return ret_conv;
23950 }
23951
23952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23953         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
23954         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23955         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
23956         return tag_ptr(ret_conv, true);
23957 }
23958
23959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23960         LDKChannelReestablish o_conv;
23961         o_conv.inner = untag_ptr(o);
23962         o_conv.is_owned = ptr_is_owned(o);
23963         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23964         o_conv = ChannelReestablish_clone(&o_conv);
23965         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23966         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
23967         return tag_ptr(ret_conv, true);
23968 }
23969
23970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23971         void* e_ptr = untag_ptr(e);
23972         CHECK_ACCESS(e_ptr);
23973         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23974         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23975         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23976         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
23977         return tag_ptr(ret_conv, true);
23978 }
23979
23980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23981         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
23982         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
23983         return ret_conv;
23984 }
23985
23986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23987         if (!ptr_is_owned(_res)) return;
23988         void* _res_ptr = untag_ptr(_res);
23989         CHECK_ACCESS(_res_ptr);
23990         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
23991         FREE(untag_ptr(_res));
23992         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
23993 }
23994
23995 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
23996         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23997         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
23998         return tag_ptr(ret_conv, true);
23999 }
24000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24001         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
24002         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
24003         return ret_conv;
24004 }
24005
24006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24007         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
24008         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24009         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
24010         return tag_ptr(ret_conv, true);
24011 }
24012
24013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24014         LDKClosingSigned o_conv;
24015         o_conv.inner = untag_ptr(o);
24016         o_conv.is_owned = ptr_is_owned(o);
24017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24018         o_conv = ClosingSigned_clone(&o_conv);
24019         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24020         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
24021         return tag_ptr(ret_conv, true);
24022 }
24023
24024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24025         void* e_ptr = untag_ptr(e);
24026         CHECK_ACCESS(e_ptr);
24027         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24028         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24029         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24030         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
24031         return tag_ptr(ret_conv, true);
24032 }
24033
24034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24035         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
24036         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
24037         return ret_conv;
24038 }
24039
24040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24041         if (!ptr_is_owned(_res)) return;
24042         void* _res_ptr = untag_ptr(_res);
24043         CHECK_ACCESS(_res_ptr);
24044         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
24045         FREE(untag_ptr(_res));
24046         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
24047 }
24048
24049 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
24050         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24051         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
24052         return tag_ptr(ret_conv, true);
24053 }
24054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24055         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
24056         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
24057         return ret_conv;
24058 }
24059
24060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24061         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
24062         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24063         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
24064         return tag_ptr(ret_conv, true);
24065 }
24066
24067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24068         LDKClosingSignedFeeRange o_conv;
24069         o_conv.inner = untag_ptr(o);
24070         o_conv.is_owned = ptr_is_owned(o);
24071         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24072         o_conv = ClosingSignedFeeRange_clone(&o_conv);
24073         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24074         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
24075         return tag_ptr(ret_conv, true);
24076 }
24077
24078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24079         void* e_ptr = untag_ptr(e);
24080         CHECK_ACCESS(e_ptr);
24081         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24082         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24083         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24084         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
24085         return tag_ptr(ret_conv, true);
24086 }
24087
24088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24089         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
24090         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
24091         return ret_conv;
24092 }
24093
24094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24095         if (!ptr_is_owned(_res)) return;
24096         void* _res_ptr = untag_ptr(_res);
24097         CHECK_ACCESS(_res_ptr);
24098         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
24099         FREE(untag_ptr(_res));
24100         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
24101 }
24102
24103 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
24104         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24105         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
24106         return tag_ptr(ret_conv, true);
24107 }
24108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24109         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
24110         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
24111         return ret_conv;
24112 }
24113
24114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24115         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
24116         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24117         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
24118         return tag_ptr(ret_conv, true);
24119 }
24120
24121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24122         LDKCommitmentSigned o_conv;
24123         o_conv.inner = untag_ptr(o);
24124         o_conv.is_owned = ptr_is_owned(o);
24125         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24126         o_conv = CommitmentSigned_clone(&o_conv);
24127         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24128         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
24129         return tag_ptr(ret_conv, true);
24130 }
24131
24132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24133         void* e_ptr = untag_ptr(e);
24134         CHECK_ACCESS(e_ptr);
24135         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24136         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24137         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24138         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
24139         return tag_ptr(ret_conv, true);
24140 }
24141
24142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24143         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
24144         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
24145         return ret_conv;
24146 }
24147
24148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24149         if (!ptr_is_owned(_res)) return;
24150         void* _res_ptr = untag_ptr(_res);
24151         CHECK_ACCESS(_res_ptr);
24152         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
24153         FREE(untag_ptr(_res));
24154         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
24155 }
24156
24157 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
24158         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24159         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
24160         return tag_ptr(ret_conv, true);
24161 }
24162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24163         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
24164         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
24165         return ret_conv;
24166 }
24167
24168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24169         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
24170         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24171         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
24172         return tag_ptr(ret_conv, true);
24173 }
24174
24175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24176         LDKFundingCreated o_conv;
24177         o_conv.inner = untag_ptr(o);
24178         o_conv.is_owned = ptr_is_owned(o);
24179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24180         o_conv = FundingCreated_clone(&o_conv);
24181         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24182         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
24183         return tag_ptr(ret_conv, true);
24184 }
24185
24186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24187         void* e_ptr = untag_ptr(e);
24188         CHECK_ACCESS(e_ptr);
24189         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24190         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24191         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24192         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
24193         return tag_ptr(ret_conv, true);
24194 }
24195
24196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24197         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
24198         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
24199         return ret_conv;
24200 }
24201
24202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24203         if (!ptr_is_owned(_res)) return;
24204         void* _res_ptr = untag_ptr(_res);
24205         CHECK_ACCESS(_res_ptr);
24206         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
24207         FREE(untag_ptr(_res));
24208         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
24209 }
24210
24211 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
24212         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24213         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
24214         return tag_ptr(ret_conv, true);
24215 }
24216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24217         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
24218         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
24219         return ret_conv;
24220 }
24221
24222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24223         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
24224         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24225         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
24226         return tag_ptr(ret_conv, true);
24227 }
24228
24229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24230         LDKFundingSigned o_conv;
24231         o_conv.inner = untag_ptr(o);
24232         o_conv.is_owned = ptr_is_owned(o);
24233         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24234         o_conv = FundingSigned_clone(&o_conv);
24235         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24236         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
24237         return tag_ptr(ret_conv, true);
24238 }
24239
24240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24241         void* e_ptr = untag_ptr(e);
24242         CHECK_ACCESS(e_ptr);
24243         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24244         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24245         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24246         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
24247         return tag_ptr(ret_conv, true);
24248 }
24249
24250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24251         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
24252         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
24253         return ret_conv;
24254 }
24255
24256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24257         if (!ptr_is_owned(_res)) return;
24258         void* _res_ptr = untag_ptr(_res);
24259         CHECK_ACCESS(_res_ptr);
24260         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
24261         FREE(untag_ptr(_res));
24262         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
24263 }
24264
24265 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
24266         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24267         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
24268         return tag_ptr(ret_conv, true);
24269 }
24270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24271         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
24272         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
24273         return ret_conv;
24274 }
24275
24276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24277         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
24278         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24279         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
24280         return tag_ptr(ret_conv, true);
24281 }
24282
24283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24284         LDKChannelReady o_conv;
24285         o_conv.inner = untag_ptr(o);
24286         o_conv.is_owned = ptr_is_owned(o);
24287         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24288         o_conv = ChannelReady_clone(&o_conv);
24289         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24290         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
24291         return tag_ptr(ret_conv, true);
24292 }
24293
24294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24295         void* e_ptr = untag_ptr(e);
24296         CHECK_ACCESS(e_ptr);
24297         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24298         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24299         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24300         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
24301         return tag_ptr(ret_conv, true);
24302 }
24303
24304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24305         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
24306         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
24307         return ret_conv;
24308 }
24309
24310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24311         if (!ptr_is_owned(_res)) return;
24312         void* _res_ptr = untag_ptr(_res);
24313         CHECK_ACCESS(_res_ptr);
24314         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
24315         FREE(untag_ptr(_res));
24316         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
24317 }
24318
24319 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
24320         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24321         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
24322         return tag_ptr(ret_conv, true);
24323 }
24324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24325         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
24326         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
24327         return ret_conv;
24328 }
24329
24330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24331         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
24332         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24333         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
24334         return tag_ptr(ret_conv, true);
24335 }
24336
24337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24338         LDKInit o_conv;
24339         o_conv.inner = untag_ptr(o);
24340         o_conv.is_owned = ptr_is_owned(o);
24341         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24342         o_conv = Init_clone(&o_conv);
24343         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24344         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
24345         return tag_ptr(ret_conv, true);
24346 }
24347
24348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24349         void* e_ptr = untag_ptr(e);
24350         CHECK_ACCESS(e_ptr);
24351         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24352         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24353         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24354         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
24355         return tag_ptr(ret_conv, true);
24356 }
24357
24358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24359         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
24360         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
24361         return ret_conv;
24362 }
24363
24364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24365         if (!ptr_is_owned(_res)) return;
24366         void* _res_ptr = untag_ptr(_res);
24367         CHECK_ACCESS(_res_ptr);
24368         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
24369         FREE(untag_ptr(_res));
24370         CResult_InitDecodeErrorZ_free(_res_conv);
24371 }
24372
24373 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
24374         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24375         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
24376         return tag_ptr(ret_conv, true);
24377 }
24378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24379         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
24380         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
24381         return ret_conv;
24382 }
24383
24384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24385         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
24386         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24387         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
24388         return tag_ptr(ret_conv, true);
24389 }
24390
24391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24392         LDKOpenChannel o_conv;
24393         o_conv.inner = untag_ptr(o);
24394         o_conv.is_owned = ptr_is_owned(o);
24395         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24396         o_conv = OpenChannel_clone(&o_conv);
24397         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24398         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
24399         return tag_ptr(ret_conv, true);
24400 }
24401
24402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24403         void* e_ptr = untag_ptr(e);
24404         CHECK_ACCESS(e_ptr);
24405         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24406         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24407         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24408         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
24409         return tag_ptr(ret_conv, true);
24410 }
24411
24412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24413         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
24414         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
24415         return ret_conv;
24416 }
24417
24418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24419         if (!ptr_is_owned(_res)) return;
24420         void* _res_ptr = untag_ptr(_res);
24421         CHECK_ACCESS(_res_ptr);
24422         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
24423         FREE(untag_ptr(_res));
24424         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
24425 }
24426
24427 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
24428         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24429         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
24430         return tag_ptr(ret_conv, true);
24431 }
24432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24433         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
24434         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
24435         return ret_conv;
24436 }
24437
24438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24439         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
24440         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24441         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
24442         return tag_ptr(ret_conv, true);
24443 }
24444
24445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24446         LDKRevokeAndACK o_conv;
24447         o_conv.inner = untag_ptr(o);
24448         o_conv.is_owned = ptr_is_owned(o);
24449         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24450         o_conv = RevokeAndACK_clone(&o_conv);
24451         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24452         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
24453         return tag_ptr(ret_conv, true);
24454 }
24455
24456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24457         void* e_ptr = untag_ptr(e);
24458         CHECK_ACCESS(e_ptr);
24459         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24460         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24461         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24462         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
24463         return tag_ptr(ret_conv, true);
24464 }
24465
24466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24467         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
24468         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
24469         return ret_conv;
24470 }
24471
24472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24473         if (!ptr_is_owned(_res)) return;
24474         void* _res_ptr = untag_ptr(_res);
24475         CHECK_ACCESS(_res_ptr);
24476         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
24477         FREE(untag_ptr(_res));
24478         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
24479 }
24480
24481 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
24482         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24483         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
24484         return tag_ptr(ret_conv, true);
24485 }
24486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24487         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
24488         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
24489         return ret_conv;
24490 }
24491
24492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24493         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
24494         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24495         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
24496         return tag_ptr(ret_conv, true);
24497 }
24498
24499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24500         LDKShutdown o_conv;
24501         o_conv.inner = untag_ptr(o);
24502         o_conv.is_owned = ptr_is_owned(o);
24503         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24504         o_conv = Shutdown_clone(&o_conv);
24505         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24506         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
24507         return tag_ptr(ret_conv, true);
24508 }
24509
24510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24511         void* e_ptr = untag_ptr(e);
24512         CHECK_ACCESS(e_ptr);
24513         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24514         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24515         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24516         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
24517         return tag_ptr(ret_conv, true);
24518 }
24519
24520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24521         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
24522         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
24523         return ret_conv;
24524 }
24525
24526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24527         if (!ptr_is_owned(_res)) return;
24528         void* _res_ptr = untag_ptr(_res);
24529         CHECK_ACCESS(_res_ptr);
24530         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
24531         FREE(untag_ptr(_res));
24532         CResult_ShutdownDecodeErrorZ_free(_res_conv);
24533 }
24534
24535 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
24536         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24537         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
24538         return tag_ptr(ret_conv, true);
24539 }
24540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24541         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
24542         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
24543         return ret_conv;
24544 }
24545
24546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24547         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
24548         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24549         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
24550         return tag_ptr(ret_conv, true);
24551 }
24552
24553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24554         LDKUpdateFailHTLC o_conv;
24555         o_conv.inner = untag_ptr(o);
24556         o_conv.is_owned = ptr_is_owned(o);
24557         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24558         o_conv = UpdateFailHTLC_clone(&o_conv);
24559         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24560         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
24561         return tag_ptr(ret_conv, true);
24562 }
24563
24564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24565         void* e_ptr = untag_ptr(e);
24566         CHECK_ACCESS(e_ptr);
24567         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24568         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24569         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24570         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
24571         return tag_ptr(ret_conv, true);
24572 }
24573
24574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24575         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
24576         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
24577         return ret_conv;
24578 }
24579
24580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24581         if (!ptr_is_owned(_res)) return;
24582         void* _res_ptr = untag_ptr(_res);
24583         CHECK_ACCESS(_res_ptr);
24584         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
24585         FREE(untag_ptr(_res));
24586         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
24587 }
24588
24589 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
24590         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24591         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
24592         return tag_ptr(ret_conv, true);
24593 }
24594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24595         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
24596         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
24597         return ret_conv;
24598 }
24599
24600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24601         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
24602         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24603         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
24604         return tag_ptr(ret_conv, true);
24605 }
24606
24607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24608         LDKUpdateFailMalformedHTLC o_conv;
24609         o_conv.inner = untag_ptr(o);
24610         o_conv.is_owned = ptr_is_owned(o);
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24612         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
24613         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24614         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
24615         return tag_ptr(ret_conv, true);
24616 }
24617
24618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24619         void* e_ptr = untag_ptr(e);
24620         CHECK_ACCESS(e_ptr);
24621         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24622         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24623         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24624         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
24625         return tag_ptr(ret_conv, true);
24626 }
24627
24628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24629         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
24630         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
24631         return ret_conv;
24632 }
24633
24634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24635         if (!ptr_is_owned(_res)) return;
24636         void* _res_ptr = untag_ptr(_res);
24637         CHECK_ACCESS(_res_ptr);
24638         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
24639         FREE(untag_ptr(_res));
24640         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
24641 }
24642
24643 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
24644         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24645         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
24646         return tag_ptr(ret_conv, true);
24647 }
24648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24649         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
24650         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
24651         return ret_conv;
24652 }
24653
24654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24655         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
24656         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24657         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
24658         return tag_ptr(ret_conv, true);
24659 }
24660
24661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24662         LDKUpdateFee o_conv;
24663         o_conv.inner = untag_ptr(o);
24664         o_conv.is_owned = ptr_is_owned(o);
24665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24666         o_conv = UpdateFee_clone(&o_conv);
24667         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24668         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
24669         return tag_ptr(ret_conv, true);
24670 }
24671
24672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24673         void* e_ptr = untag_ptr(e);
24674         CHECK_ACCESS(e_ptr);
24675         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24676         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24677         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24678         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
24679         return tag_ptr(ret_conv, true);
24680 }
24681
24682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24683         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
24684         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
24685         return ret_conv;
24686 }
24687
24688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24689         if (!ptr_is_owned(_res)) return;
24690         void* _res_ptr = untag_ptr(_res);
24691         CHECK_ACCESS(_res_ptr);
24692         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
24693         FREE(untag_ptr(_res));
24694         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
24695 }
24696
24697 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
24698         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24699         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
24700         return tag_ptr(ret_conv, true);
24701 }
24702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24703         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
24704         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
24705         return ret_conv;
24706 }
24707
24708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24709         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
24710         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24711         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
24712         return tag_ptr(ret_conv, true);
24713 }
24714
24715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24716         LDKUpdateFulfillHTLC o_conv;
24717         o_conv.inner = untag_ptr(o);
24718         o_conv.is_owned = ptr_is_owned(o);
24719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24720         o_conv = UpdateFulfillHTLC_clone(&o_conv);
24721         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24722         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
24723         return tag_ptr(ret_conv, true);
24724 }
24725
24726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24727         void* e_ptr = untag_ptr(e);
24728         CHECK_ACCESS(e_ptr);
24729         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24730         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24731         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24732         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
24733         return tag_ptr(ret_conv, true);
24734 }
24735
24736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24737         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
24738         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
24739         return ret_conv;
24740 }
24741
24742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24743         if (!ptr_is_owned(_res)) return;
24744         void* _res_ptr = untag_ptr(_res);
24745         CHECK_ACCESS(_res_ptr);
24746         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
24747         FREE(untag_ptr(_res));
24748         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
24749 }
24750
24751 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
24752         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24753         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
24754         return tag_ptr(ret_conv, true);
24755 }
24756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24757         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
24758         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
24759         return ret_conv;
24760 }
24761
24762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24763         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
24764         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24765         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
24766         return tag_ptr(ret_conv, true);
24767 }
24768
24769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24770         LDKUpdateAddHTLC o_conv;
24771         o_conv.inner = untag_ptr(o);
24772         o_conv.is_owned = ptr_is_owned(o);
24773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24774         o_conv = UpdateAddHTLC_clone(&o_conv);
24775         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24776         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
24777         return tag_ptr(ret_conv, true);
24778 }
24779
24780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24781         void* e_ptr = untag_ptr(e);
24782         CHECK_ACCESS(e_ptr);
24783         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24784         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24785         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24786         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
24787         return tag_ptr(ret_conv, true);
24788 }
24789
24790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24791         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
24792         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
24793         return ret_conv;
24794 }
24795
24796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24797         if (!ptr_is_owned(_res)) return;
24798         void* _res_ptr = untag_ptr(_res);
24799         CHECK_ACCESS(_res_ptr);
24800         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
24801         FREE(untag_ptr(_res));
24802         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
24803 }
24804
24805 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
24806         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24807         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
24808         return tag_ptr(ret_conv, true);
24809 }
24810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24811         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
24812         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
24813         return ret_conv;
24814 }
24815
24816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24817         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
24818         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24819         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
24820         return tag_ptr(ret_conv, true);
24821 }
24822
24823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24824         LDKOnionMessage o_conv;
24825         o_conv.inner = untag_ptr(o);
24826         o_conv.is_owned = ptr_is_owned(o);
24827         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24828         o_conv = OnionMessage_clone(&o_conv);
24829         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24830         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
24831         return tag_ptr(ret_conv, true);
24832 }
24833
24834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24835         void* e_ptr = untag_ptr(e);
24836         CHECK_ACCESS(e_ptr);
24837         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24838         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24839         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24840         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
24841         return tag_ptr(ret_conv, true);
24842 }
24843
24844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24845         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
24846         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
24847         return ret_conv;
24848 }
24849
24850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24851         if (!ptr_is_owned(_res)) return;
24852         void* _res_ptr = untag_ptr(_res);
24853         CHECK_ACCESS(_res_ptr);
24854         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
24855         FREE(untag_ptr(_res));
24856         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
24857 }
24858
24859 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
24860         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24861         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
24862         return tag_ptr(ret_conv, true);
24863 }
24864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24865         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
24866         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
24867         return ret_conv;
24868 }
24869
24870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24871         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
24872         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24873         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
24874         return tag_ptr(ret_conv, true);
24875 }
24876
24877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24878         LDKPing o_conv;
24879         o_conv.inner = untag_ptr(o);
24880         o_conv.is_owned = ptr_is_owned(o);
24881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24882         o_conv = Ping_clone(&o_conv);
24883         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24884         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
24885         return tag_ptr(ret_conv, true);
24886 }
24887
24888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24889         void* e_ptr = untag_ptr(e);
24890         CHECK_ACCESS(e_ptr);
24891         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24892         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24893         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24894         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
24895         return tag_ptr(ret_conv, true);
24896 }
24897
24898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24899         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
24900         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
24901         return ret_conv;
24902 }
24903
24904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24905         if (!ptr_is_owned(_res)) return;
24906         void* _res_ptr = untag_ptr(_res);
24907         CHECK_ACCESS(_res_ptr);
24908         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
24909         FREE(untag_ptr(_res));
24910         CResult_PingDecodeErrorZ_free(_res_conv);
24911 }
24912
24913 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
24914         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24915         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
24916         return tag_ptr(ret_conv, true);
24917 }
24918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24919         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
24920         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
24921         return ret_conv;
24922 }
24923
24924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24925         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
24926         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24927         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
24928         return tag_ptr(ret_conv, true);
24929 }
24930
24931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24932         LDKPong o_conv;
24933         o_conv.inner = untag_ptr(o);
24934         o_conv.is_owned = ptr_is_owned(o);
24935         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24936         o_conv = Pong_clone(&o_conv);
24937         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24938         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
24939         return tag_ptr(ret_conv, true);
24940 }
24941
24942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24943         void* e_ptr = untag_ptr(e);
24944         CHECK_ACCESS(e_ptr);
24945         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24946         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24947         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24948         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
24949         return tag_ptr(ret_conv, true);
24950 }
24951
24952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24953         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
24954         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
24955         return ret_conv;
24956 }
24957
24958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24959         if (!ptr_is_owned(_res)) return;
24960         void* _res_ptr = untag_ptr(_res);
24961         CHECK_ACCESS(_res_ptr);
24962         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
24963         FREE(untag_ptr(_res));
24964         CResult_PongDecodeErrorZ_free(_res_conv);
24965 }
24966
24967 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
24968         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24969         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
24970         return tag_ptr(ret_conv, true);
24971 }
24972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24973         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
24974         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
24975         return ret_conv;
24976 }
24977
24978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24979         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
24980         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24981         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
24982         return tag_ptr(ret_conv, true);
24983 }
24984
24985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24986         LDKUnsignedChannelAnnouncement o_conv;
24987         o_conv.inner = untag_ptr(o);
24988         o_conv.is_owned = ptr_is_owned(o);
24989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24990         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
24991         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24992         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
24993         return tag_ptr(ret_conv, true);
24994 }
24995
24996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24997         void* e_ptr = untag_ptr(e);
24998         CHECK_ACCESS(e_ptr);
24999         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25000         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25001         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25002         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
25003         return tag_ptr(ret_conv, true);
25004 }
25005
25006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25007         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25008         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25009         return ret_conv;
25010 }
25011
25012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25013         if (!ptr_is_owned(_res)) return;
25014         void* _res_ptr = untag_ptr(_res);
25015         CHECK_ACCESS(_res_ptr);
25016         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25017         FREE(untag_ptr(_res));
25018         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
25019 }
25020
25021 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25022         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25023         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
25024         return tag_ptr(ret_conv, true);
25025 }
25026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25027         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25028         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25029         return ret_conv;
25030 }
25031
25032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25033         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25034         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25035         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25036         return tag_ptr(ret_conv, true);
25037 }
25038
25039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25040         LDKChannelAnnouncement o_conv;
25041         o_conv.inner = untag_ptr(o);
25042         o_conv.is_owned = ptr_is_owned(o);
25043         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25044         o_conv = ChannelAnnouncement_clone(&o_conv);
25045         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25046         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
25047         return tag_ptr(ret_conv, true);
25048 }
25049
25050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25051         void* e_ptr = untag_ptr(e);
25052         CHECK_ACCESS(e_ptr);
25053         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25054         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25055         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25056         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
25057         return tag_ptr(ret_conv, true);
25058 }
25059
25060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25061         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25062         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25063         return ret_conv;
25064 }
25065
25066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25067         if (!ptr_is_owned(_res)) return;
25068         void* _res_ptr = untag_ptr(_res);
25069         CHECK_ACCESS(_res_ptr);
25070         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25071         FREE(untag_ptr(_res));
25072         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
25073 }
25074
25075 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25076         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25077         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
25078         return tag_ptr(ret_conv, true);
25079 }
25080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25081         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25082         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25083         return ret_conv;
25084 }
25085
25086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25087         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25088         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25089         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25090         return tag_ptr(ret_conv, true);
25091 }
25092
25093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25094         LDKUnsignedChannelUpdate o_conv;
25095         o_conv.inner = untag_ptr(o);
25096         o_conv.is_owned = ptr_is_owned(o);
25097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25098         o_conv = UnsignedChannelUpdate_clone(&o_conv);
25099         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25100         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
25101         return tag_ptr(ret_conv, true);
25102 }
25103
25104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25105         void* e_ptr = untag_ptr(e);
25106         CHECK_ACCESS(e_ptr);
25107         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25108         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25109         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25110         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
25111         return tag_ptr(ret_conv, true);
25112 }
25113
25114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25115         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
25116         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
25117         return ret_conv;
25118 }
25119
25120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25121         if (!ptr_is_owned(_res)) return;
25122         void* _res_ptr = untag_ptr(_res);
25123         CHECK_ACCESS(_res_ptr);
25124         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
25125         FREE(untag_ptr(_res));
25126         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
25127 }
25128
25129 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25130         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25131         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
25132         return tag_ptr(ret_conv, true);
25133 }
25134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25135         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25136         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25137         return ret_conv;
25138 }
25139
25140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25141         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25142         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25143         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
25144         return tag_ptr(ret_conv, true);
25145 }
25146
25147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25148         LDKChannelUpdate o_conv;
25149         o_conv.inner = untag_ptr(o);
25150         o_conv.is_owned = ptr_is_owned(o);
25151         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25152         o_conv = ChannelUpdate_clone(&o_conv);
25153         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25154         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
25155         return tag_ptr(ret_conv, true);
25156 }
25157
25158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25159         void* e_ptr = untag_ptr(e);
25160         CHECK_ACCESS(e_ptr);
25161         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25162         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25163         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25164         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
25165         return tag_ptr(ret_conv, true);
25166 }
25167
25168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25169         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
25170         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
25171         return ret_conv;
25172 }
25173
25174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25175         if (!ptr_is_owned(_res)) return;
25176         void* _res_ptr = untag_ptr(_res);
25177         CHECK_ACCESS(_res_ptr);
25178         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
25179         FREE(untag_ptr(_res));
25180         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
25181 }
25182
25183 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25184         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25185         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
25186         return tag_ptr(ret_conv, true);
25187 }
25188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25189         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25190         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25191         return ret_conv;
25192 }
25193
25194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25195         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25196         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25197         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
25198         return tag_ptr(ret_conv, true);
25199 }
25200
25201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25202         LDKErrorMessage o_conv;
25203         o_conv.inner = untag_ptr(o);
25204         o_conv.is_owned = ptr_is_owned(o);
25205         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25206         o_conv = ErrorMessage_clone(&o_conv);
25207         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25208         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
25209         return tag_ptr(ret_conv, true);
25210 }
25211
25212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25213         void* e_ptr = untag_ptr(e);
25214         CHECK_ACCESS(e_ptr);
25215         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25216         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25217         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25218         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
25219         return tag_ptr(ret_conv, true);
25220 }
25221
25222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25223         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
25224         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
25225         return ret_conv;
25226 }
25227
25228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25229         if (!ptr_is_owned(_res)) return;
25230         void* _res_ptr = untag_ptr(_res);
25231         CHECK_ACCESS(_res_ptr);
25232         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
25233         FREE(untag_ptr(_res));
25234         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
25235 }
25236
25237 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
25238         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25239         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
25240         return tag_ptr(ret_conv, true);
25241 }
25242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25243         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
25244         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
25245         return ret_conv;
25246 }
25247
25248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25249         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
25250         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25251         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
25252         return tag_ptr(ret_conv, true);
25253 }
25254
25255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25256         LDKWarningMessage o_conv;
25257         o_conv.inner = untag_ptr(o);
25258         o_conv.is_owned = ptr_is_owned(o);
25259         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25260         o_conv = WarningMessage_clone(&o_conv);
25261         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25262         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
25263         return tag_ptr(ret_conv, true);
25264 }
25265
25266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25267         void* e_ptr = untag_ptr(e);
25268         CHECK_ACCESS(e_ptr);
25269         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25270         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25271         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25272         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
25273         return tag_ptr(ret_conv, true);
25274 }
25275
25276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25277         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
25278         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
25279         return ret_conv;
25280 }
25281
25282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25283         if (!ptr_is_owned(_res)) return;
25284         void* _res_ptr = untag_ptr(_res);
25285         CHECK_ACCESS(_res_ptr);
25286         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
25287         FREE(untag_ptr(_res));
25288         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
25289 }
25290
25291 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
25292         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25293         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
25294         return tag_ptr(ret_conv, true);
25295 }
25296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25297         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
25298         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
25299         return ret_conv;
25300 }
25301
25302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25303         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
25304         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25305         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
25306         return tag_ptr(ret_conv, true);
25307 }
25308
25309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25310         LDKUnsignedNodeAnnouncement o_conv;
25311         o_conv.inner = untag_ptr(o);
25312         o_conv.is_owned = ptr_is_owned(o);
25313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25314         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
25315         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25316         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
25317         return tag_ptr(ret_conv, true);
25318 }
25319
25320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25321         void* e_ptr = untag_ptr(e);
25322         CHECK_ACCESS(e_ptr);
25323         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25324         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25325         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25326         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
25327         return tag_ptr(ret_conv, true);
25328 }
25329
25330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25331         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25332         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25333         return ret_conv;
25334 }
25335
25336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25337         if (!ptr_is_owned(_res)) return;
25338         void* _res_ptr = untag_ptr(_res);
25339         CHECK_ACCESS(_res_ptr);
25340         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
25341         FREE(untag_ptr(_res));
25342         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
25343 }
25344
25345 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25346         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25347         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
25348         return tag_ptr(ret_conv, true);
25349 }
25350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25351         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25352         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25353         return ret_conv;
25354 }
25355
25356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25357         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
25358         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25359         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
25360         return tag_ptr(ret_conv, true);
25361 }
25362
25363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25364         LDKNodeAnnouncement o_conv;
25365         o_conv.inner = untag_ptr(o);
25366         o_conv.is_owned = ptr_is_owned(o);
25367         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25368         o_conv = NodeAnnouncement_clone(&o_conv);
25369         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25370         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
25371         return tag_ptr(ret_conv, true);
25372 }
25373
25374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25375         void* e_ptr = untag_ptr(e);
25376         CHECK_ACCESS(e_ptr);
25377         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25378         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25379         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25380         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
25381         return tag_ptr(ret_conv, true);
25382 }
25383
25384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25385         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25386         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25387         return ret_conv;
25388 }
25389
25390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25391         if (!ptr_is_owned(_res)) return;
25392         void* _res_ptr = untag_ptr(_res);
25393         CHECK_ACCESS(_res_ptr);
25394         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
25395         FREE(untag_ptr(_res));
25396         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
25397 }
25398
25399 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25400         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25401         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
25402         return tag_ptr(ret_conv, true);
25403 }
25404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25405         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25406         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25407         return ret_conv;
25408 }
25409
25410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25411         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
25412         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25413         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
25414         return tag_ptr(ret_conv, true);
25415 }
25416
25417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25418         LDKQueryShortChannelIds o_conv;
25419         o_conv.inner = untag_ptr(o);
25420         o_conv.is_owned = ptr_is_owned(o);
25421         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25422         o_conv = QueryShortChannelIds_clone(&o_conv);
25423         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25424         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
25425         return tag_ptr(ret_conv, true);
25426 }
25427
25428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25429         void* e_ptr = untag_ptr(e);
25430         CHECK_ACCESS(e_ptr);
25431         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25432         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25433         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25434         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
25435         return tag_ptr(ret_conv, true);
25436 }
25437
25438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25439         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
25440         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
25441         return ret_conv;
25442 }
25443
25444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25445         if (!ptr_is_owned(_res)) return;
25446         void* _res_ptr = untag_ptr(_res);
25447         CHECK_ACCESS(_res_ptr);
25448         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
25449         FREE(untag_ptr(_res));
25450         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
25451 }
25452
25453 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
25454         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25455         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
25456         return tag_ptr(ret_conv, true);
25457 }
25458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25459         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
25460         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
25461         return ret_conv;
25462 }
25463
25464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25465         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
25466         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25467         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
25468         return tag_ptr(ret_conv, true);
25469 }
25470
25471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25472         LDKReplyShortChannelIdsEnd o_conv;
25473         o_conv.inner = untag_ptr(o);
25474         o_conv.is_owned = ptr_is_owned(o);
25475         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25476         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
25477         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25478         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
25479         return tag_ptr(ret_conv, true);
25480 }
25481
25482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25483         void* e_ptr = untag_ptr(e);
25484         CHECK_ACCESS(e_ptr);
25485         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25486         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25487         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25488         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
25489         return tag_ptr(ret_conv, true);
25490 }
25491
25492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25493         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
25494         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
25495         return ret_conv;
25496 }
25497
25498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25499         if (!ptr_is_owned(_res)) return;
25500         void* _res_ptr = untag_ptr(_res);
25501         CHECK_ACCESS(_res_ptr);
25502         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
25503         FREE(untag_ptr(_res));
25504         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
25505 }
25506
25507 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
25508         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25509         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
25510         return tag_ptr(ret_conv, true);
25511 }
25512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25513         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
25514         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
25515         return ret_conv;
25516 }
25517
25518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25519         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
25520         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25521         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
25522         return tag_ptr(ret_conv, true);
25523 }
25524
25525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25526         LDKQueryChannelRange o_conv;
25527         o_conv.inner = untag_ptr(o);
25528         o_conv.is_owned = ptr_is_owned(o);
25529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25530         o_conv = QueryChannelRange_clone(&o_conv);
25531         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25532         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
25533         return tag_ptr(ret_conv, true);
25534 }
25535
25536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25537         void* e_ptr = untag_ptr(e);
25538         CHECK_ACCESS(e_ptr);
25539         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25540         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25541         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25542         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
25543         return tag_ptr(ret_conv, true);
25544 }
25545
25546 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25547         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
25548         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
25549         return ret_conv;
25550 }
25551
25552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25553         if (!ptr_is_owned(_res)) return;
25554         void* _res_ptr = untag_ptr(_res);
25555         CHECK_ACCESS(_res_ptr);
25556         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
25557         FREE(untag_ptr(_res));
25558         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
25559 }
25560
25561 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
25562         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25563         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
25564         return tag_ptr(ret_conv, true);
25565 }
25566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25567         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
25568         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
25569         return ret_conv;
25570 }
25571
25572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25573         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
25574         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25575         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
25576         return tag_ptr(ret_conv, true);
25577 }
25578
25579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25580         LDKReplyChannelRange o_conv;
25581         o_conv.inner = untag_ptr(o);
25582         o_conv.is_owned = ptr_is_owned(o);
25583         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25584         o_conv = ReplyChannelRange_clone(&o_conv);
25585         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25586         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
25587         return tag_ptr(ret_conv, true);
25588 }
25589
25590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25591         void* e_ptr = untag_ptr(e);
25592         CHECK_ACCESS(e_ptr);
25593         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25594         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25595         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25596         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
25597         return tag_ptr(ret_conv, true);
25598 }
25599
25600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25601         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
25602         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
25603         return ret_conv;
25604 }
25605
25606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25607         if (!ptr_is_owned(_res)) return;
25608         void* _res_ptr = untag_ptr(_res);
25609         CHECK_ACCESS(_res_ptr);
25610         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
25611         FREE(untag_ptr(_res));
25612         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
25613 }
25614
25615 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
25616         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25617         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
25618         return tag_ptr(ret_conv, true);
25619 }
25620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25621         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
25622         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
25623         return ret_conv;
25624 }
25625
25626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25627         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
25628         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25629         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
25630         return tag_ptr(ret_conv, true);
25631 }
25632
25633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25634         LDKGossipTimestampFilter o_conv;
25635         o_conv.inner = untag_ptr(o);
25636         o_conv.is_owned = ptr_is_owned(o);
25637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25638         o_conv = GossipTimestampFilter_clone(&o_conv);
25639         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25640         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
25641         return tag_ptr(ret_conv, true);
25642 }
25643
25644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25645         void* e_ptr = untag_ptr(e);
25646         CHECK_ACCESS(e_ptr);
25647         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25648         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25649         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25650         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
25651         return tag_ptr(ret_conv, true);
25652 }
25653
25654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25655         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
25656         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
25657         return ret_conv;
25658 }
25659
25660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25661         if (!ptr_is_owned(_res)) return;
25662         void* _res_ptr = untag_ptr(_res);
25663         CHECK_ACCESS(_res_ptr);
25664         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
25665         FREE(untag_ptr(_res));
25666         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
25667 }
25668
25669 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
25670         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25671         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
25672         return tag_ptr(ret_conv, true);
25673 }
25674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25675         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
25676         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
25677         return ret_conv;
25678 }
25679
25680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25681         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
25682         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25683         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
25684         return tag_ptr(ret_conv, true);
25685 }
25686
25687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25688         LDKCVec_PhantomRouteHintsZ _res_constr;
25689         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25690         if (_res_constr.datalen > 0)
25691                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
25692         else
25693                 _res_constr.data = NULL;
25694         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25695         for (size_t t = 0; t < _res_constr.datalen; t++) {
25696                 int64_t _res_conv_19 = _res_vals[t];
25697                 LDKPhantomRouteHints _res_conv_19_conv;
25698                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
25699                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
25700                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
25701                 _res_constr.data[t] = _res_conv_19_conv;
25702         }
25703         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25704         CVec_PhantomRouteHintsZ_free(_res_constr);
25705 }
25706
25707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25708         LDKInvoice o_conv;
25709         o_conv.inner = untag_ptr(o);
25710         o_conv.is_owned = ptr_is_owned(o);
25711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25712         o_conv = Invoice_clone(&o_conv);
25713         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25714         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
25715         return tag_ptr(ret_conv, true);
25716 }
25717
25718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25719         void* e_ptr = untag_ptr(e);
25720         CHECK_ACCESS(e_ptr);
25721         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
25722         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
25723         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25724         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
25725         return tag_ptr(ret_conv, true);
25726 }
25727
25728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25729         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
25730         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
25731         return ret_conv;
25732 }
25733
25734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25735         if (!ptr_is_owned(_res)) return;
25736         void* _res_ptr = untag_ptr(_res);
25737         CHECK_ACCESS(_res_ptr);
25738         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
25739         FREE(untag_ptr(_res));
25740         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
25741 }
25742
25743 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
25744         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25745         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
25746         return tag_ptr(ret_conv, true);
25747 }
25748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25749         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
25750         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
25751         return ret_conv;
25752 }
25753
25754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25755         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
25756         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25757         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
25758         return tag_ptr(ret_conv, true);
25759 }
25760
25761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
25762         void* o_ptr = untag_ptr(o);
25763         CHECK_ACCESS(o_ptr);
25764         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
25765         if (o_conv.free == LDKFilter_JCalls_free) {
25766                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25767                 LDKFilter_JCalls_cloned(&o_conv);
25768         }
25769         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25770         *ret_copy = COption_FilterZ_some(o_conv);
25771         int64_t ret_ref = tag_ptr(ret_copy, true);
25772         return ret_ref;
25773 }
25774
25775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
25776         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25777         *ret_copy = COption_FilterZ_none();
25778         int64_t ret_ref = tag_ptr(ret_copy, true);
25779         return ret_ref;
25780 }
25781
25782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25783         if (!ptr_is_owned(_res)) return;
25784         void* _res_ptr = untag_ptr(_res);
25785         CHECK_ACCESS(_res_ptr);
25786         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
25787         FREE(untag_ptr(_res));
25788         COption_FilterZ_free(_res_conv);
25789 }
25790
25791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25792         LDKLockedChannelMonitor o_conv;
25793         o_conv.inner = untag_ptr(o);
25794         o_conv.is_owned = ptr_is_owned(o);
25795         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25796         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
25797         
25798         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25799         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
25800         return tag_ptr(ret_conv, true);
25801 }
25802
25803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
25804         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25805         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
25806         return tag_ptr(ret_conv, true);
25807 }
25808
25809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25810         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
25811         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
25812         return ret_conv;
25813 }
25814
25815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25816         if (!ptr_is_owned(_res)) return;
25817         void* _res_ptr = untag_ptr(_res);
25818         CHECK_ACCESS(_res_ptr);
25819         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
25820         FREE(untag_ptr(_res));
25821         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
25822 }
25823
25824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25825         LDKCVec_OutPointZ _res_constr;
25826         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25827         if (_res_constr.datalen > 0)
25828                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
25829         else
25830                 _res_constr.data = NULL;
25831         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25832         for (size_t k = 0; k < _res_constr.datalen; k++) {
25833                 int64_t _res_conv_10 = _res_vals[k];
25834                 LDKOutPoint _res_conv_10_conv;
25835                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
25836                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
25837                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
25838                 _res_constr.data[k] = _res_conv_10_conv;
25839         }
25840         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25841         CVec_OutPointZ_free(_res_constr);
25842 }
25843
25844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorUpdateIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25845         LDKCVec_MonitorUpdateIdZ _res_constr;
25846         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25847         if (_res_constr.datalen > 0)
25848                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
25849         else
25850                 _res_constr.data = NULL;
25851         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25852         for (size_t r = 0; r < _res_constr.datalen; r++) {
25853                 int64_t _res_conv_17 = _res_vals[r];
25854                 LDKMonitorUpdateId _res_conv_17_conv;
25855                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
25856                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
25857                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
25858                 _res_constr.data[r] = _res_conv_17_conv;
25859         }
25860         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25861         CVec_MonitorUpdateIdZ_free(_res_constr);
25862 }
25863
25864 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
25865         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
25866         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
25867         return tag_ptr(ret_conv, true);
25868 }
25869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25870         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
25871         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
25872         return ret_conv;
25873 }
25874
25875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25876         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
25877         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
25878         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
25879         return tag_ptr(ret_conv, true);
25880 }
25881
25882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
25883         LDKOutPoint a_conv;
25884         a_conv.inner = untag_ptr(a);
25885         a_conv.is_owned = ptr_is_owned(a);
25886         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25887         a_conv = OutPoint_clone(&a_conv);
25888         LDKCVec_MonitorUpdateIdZ b_constr;
25889         b_constr.datalen = (*env)->GetArrayLength(env, b);
25890         if (b_constr.datalen > 0)
25891                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
25892         else
25893                 b_constr.data = NULL;
25894         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
25895         for (size_t r = 0; r < b_constr.datalen; r++) {
25896                 int64_t b_conv_17 = b_vals[r];
25897                 LDKMonitorUpdateId b_conv_17_conv;
25898                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
25899                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
25900                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
25901                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
25902                 b_constr.data[r] = b_conv_17_conv;
25903         }
25904         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
25905         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
25906         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
25907         return tag_ptr(ret_conv, true);
25908 }
25909
25910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25911         if (!ptr_is_owned(_res)) return;
25912         void* _res_ptr = untag_ptr(_res);
25913         CHECK_ACCESS(_res_ptr);
25914         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
25915         FREE(untag_ptr(_res));
25916         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
25917 }
25918
25919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorUpdateIdZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25920         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
25921         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25922         if (_res_constr.datalen > 0)
25923                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
25924         else
25925                 _res_constr.data = NULL;
25926         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25927         for (size_t p = 0; p < _res_constr.datalen; p++) {
25928                 int64_t _res_conv_41 = _res_vals[p];
25929                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
25930                 CHECK_ACCESS(_res_conv_41_ptr);
25931                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
25932                 FREE(untag_ptr(_res_conv_41));
25933                 _res_constr.data[p] = _res_conv_41_conv;
25934         }
25935         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25936         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
25937 }
25938
25939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25940         if (!ptr_is_owned(this_ptr)) return;
25941         void* this_ptr_ptr = untag_ptr(this_ptr);
25942         CHECK_ACCESS(this_ptr_ptr);
25943         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
25944         FREE(untag_ptr(this_ptr));
25945         PaymentPurpose_free(this_ptr_conv);
25946 }
25947
25948 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
25949         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25950         *ret_copy = PaymentPurpose_clone(arg);
25951         int64_t ret_ref = tag_ptr(ret_copy, true);
25952         return ret_ref;
25953 }
25954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25955         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
25956         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
25957         return ret_conv;
25958 }
25959
25960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25961         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
25962         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25963         *ret_copy = PaymentPurpose_clone(orig_conv);
25964         int64_t ret_ref = tag_ptr(ret_copy, true);
25965         return ret_ref;
25966 }
25967
25968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
25969         LDKThirtyTwoBytes payment_preimage_ref;
25970         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25971         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25972         LDKThirtyTwoBytes payment_secret_ref;
25973         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
25974         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
25975         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25976         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
25977         int64_t ret_ref = tag_ptr(ret_copy, true);
25978         return ret_ref;
25979 }
25980
25981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
25982         LDKThirtyTwoBytes a_ref;
25983         CHECK((*env)->GetArrayLength(env, a) == 32);
25984         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
25985         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25986         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
25987         int64_t ret_ref = tag_ptr(ret_copy, true);
25988         return ret_ref;
25989 }
25990
25991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
25992         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
25993         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
25994         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25995         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25996         CVec_u8Z_free(ret_var);
25997         return ret_arr;
25998 }
25999
26000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26001         LDKu8slice ser_ref;
26002         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26003         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26004         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
26005         *ret_conv = PaymentPurpose_read(ser_ref);
26006         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26007         return tag_ptr(ret_conv, true);
26008 }
26009
26010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26011         if (!ptr_is_owned(this_ptr)) return;
26012         void* this_ptr_ptr = untag_ptr(this_ptr);
26013         CHECK_ACCESS(this_ptr_ptr);
26014         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
26015         FREE(untag_ptr(this_ptr));
26016         ClosureReason_free(this_ptr_conv);
26017 }
26018
26019 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
26020         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26021         *ret_copy = ClosureReason_clone(arg);
26022         int64_t ret_ref = tag_ptr(ret_copy, true);
26023         return ret_ref;
26024 }
26025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26026         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
26027         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
26028         return ret_conv;
26029 }
26030
26031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26032         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
26033         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26034         *ret_copy = ClosureReason_clone(orig_conv);
26035         int64_t ret_ref = tag_ptr(ret_copy, true);
26036         return ret_ref;
26037 }
26038
26039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
26040         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
26041         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26042         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
26043         int64_t ret_ref = tag_ptr(ret_copy, true);
26044         return ret_ref;
26045 }
26046
26047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
26048         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26049         *ret_copy = ClosureReason_holder_force_closed();
26050         int64_t ret_ref = tag_ptr(ret_copy, true);
26051         return ret_ref;
26052 }
26053
26054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
26055         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26056         *ret_copy = ClosureReason_cooperative_closure();
26057         int64_t ret_ref = tag_ptr(ret_copy, true);
26058         return ret_ref;
26059 }
26060
26061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
26062         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26063         *ret_copy = ClosureReason_commitment_tx_confirmed();
26064         int64_t ret_ref = tag_ptr(ret_copy, true);
26065         return ret_ref;
26066 }
26067
26068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
26069         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26070         *ret_copy = ClosureReason_funding_timed_out();
26071         int64_t ret_ref = tag_ptr(ret_copy, true);
26072         return ret_ref;
26073 }
26074
26075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
26076         LDKStr err_conv = java_to_owned_str(env, err);
26077         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26078         *ret_copy = ClosureReason_processing_error(err_conv);
26079         int64_t ret_ref = tag_ptr(ret_copy, true);
26080         return ret_ref;
26081 }
26082
26083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
26084         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26085         *ret_copy = ClosureReason_disconnected_peer();
26086         int64_t ret_ref = tag_ptr(ret_copy, true);
26087         return ret_ref;
26088 }
26089
26090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
26091         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26092         *ret_copy = ClosureReason_outdated_channel_manager();
26093         int64_t ret_ref = tag_ptr(ret_copy, true);
26094         return ret_ref;
26095 }
26096
26097 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26098         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
26099         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
26100         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
26101         return ret_conv;
26102 }
26103
26104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
26105         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
26106         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
26107         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26108         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26109         CVec_u8Z_free(ret_var);
26110         return ret_arr;
26111 }
26112
26113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26114         LDKu8slice ser_ref;
26115         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26116         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26117         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
26118         *ret_conv = ClosureReason_read(ser_ref);
26119         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26120         return tag_ptr(ret_conv, true);
26121 }
26122
26123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26124         if (!ptr_is_owned(this_ptr)) return;
26125         void* this_ptr_ptr = untag_ptr(this_ptr);
26126         CHECK_ACCESS(this_ptr_ptr);
26127         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
26128         FREE(untag_ptr(this_ptr));
26129         HTLCDestination_free(this_ptr_conv);
26130 }
26131
26132 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
26133         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26134         *ret_copy = HTLCDestination_clone(arg);
26135         int64_t ret_ref = tag_ptr(ret_copy, true);
26136         return ret_ref;
26137 }
26138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26139         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
26140         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
26141         return ret_conv;
26142 }
26143
26144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26145         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
26146         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26147         *ret_copy = HTLCDestination_clone(orig_conv);
26148         int64_t ret_ref = tag_ptr(ret_copy, true);
26149         return ret_ref;
26150 }
26151
26152 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) {
26153         LDKPublicKey node_id_ref;
26154         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26155         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26156         LDKThirtyTwoBytes channel_id_ref;
26157         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26158         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26159         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26160         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
26161         int64_t ret_ref = tag_ptr(ret_copy, true);
26162         return ret_ref;
26163 }
26164
26165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
26166         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26167         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
26168         int64_t ret_ref = tag_ptr(ret_copy, true);
26169         return ret_ref;
26170 }
26171
26172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1invalid_1forward(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
26173         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26174         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
26175         int64_t ret_ref = tag_ptr(ret_copy, true);
26176         return ret_ref;
26177 }
26178
26179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
26180         LDKThirtyTwoBytes payment_hash_ref;
26181         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26182         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26183         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26184         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
26185         int64_t ret_ref = tag_ptr(ret_copy, true);
26186         return ret_ref;
26187 }
26188
26189 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26190         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
26191         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
26192         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
26193         return ret_conv;
26194 }
26195
26196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
26197         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
26198         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
26199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26201         CVec_u8Z_free(ret_var);
26202         return ret_arr;
26203 }
26204
26205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26206         LDKu8slice ser_ref;
26207         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26208         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26209         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
26210         *ret_conv = HTLCDestination_read(ser_ref);
26211         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26212         return tag_ptr(ret_conv, true);
26213 }
26214
26215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26216         if (!ptr_is_owned(this_ptr)) return;
26217         void* this_ptr_ptr = untag_ptr(this_ptr);
26218         CHECK_ACCESS(this_ptr_ptr);
26219         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
26220         FREE(untag_ptr(this_ptr));
26221         Event_free(this_ptr_conv);
26222 }
26223
26224 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
26225         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26226         *ret_copy = Event_clone(arg);
26227         int64_t ret_ref = tag_ptr(ret_copy, true);
26228         return ret_ref;
26229 }
26230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26231         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
26232         int64_t ret_conv = Event_clone_ptr(arg_conv);
26233         return ret_conv;
26234 }
26235
26236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26237         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
26238         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26239         *ret_copy = Event_clone(orig_conv);
26240         int64_t ret_ref = tag_ptr(ret_copy, true);
26241         return ret_ref;
26242 }
26243
26244 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) {
26245         LDKThirtyTwoBytes temporary_channel_id_ref;
26246         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
26247         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
26248         LDKPublicKey counterparty_node_id_ref;
26249         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26250         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26251         LDKCVec_u8Z output_script_ref;
26252         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
26253         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
26254         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
26255         LDKU128 user_channel_id_ref;
26256         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26257         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26258         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26259         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
26260         int64_t ret_ref = tag_ptr(ret_copy, true);
26261         return ret_ref;
26262 }
26263
26264 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) {
26265         LDKPublicKey receiver_node_id_ref;
26266         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
26267         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
26268         LDKThirtyTwoBytes payment_hash_ref;
26269         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26270         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26271         void* purpose_ptr = untag_ptr(purpose);
26272         CHECK_ACCESS(purpose_ptr);
26273         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
26274         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
26275         LDKThirtyTwoBytes via_channel_id_ref;
26276         CHECK((*env)->GetArrayLength(env, via_channel_id) == 32);
26277         (*env)->GetByteArrayRegion(env, via_channel_id, 0, 32, via_channel_id_ref.data);
26278         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
26279         CHECK_ACCESS(via_user_channel_id_ptr);
26280         LDKCOption_u128Z via_user_channel_id_conv = *(LDKCOption_u128Z*)(via_user_channel_id_ptr);
26281         via_user_channel_id_conv = COption_u128Z_clone((LDKCOption_u128Z*)untag_ptr(via_user_channel_id));
26282         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26283         *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);
26284         int64_t ret_ref = tag_ptr(ret_copy, true);
26285         return ret_ref;
26286 }
26287
26288 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) {
26289         LDKPublicKey receiver_node_id_ref;
26290         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
26291         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
26292         LDKThirtyTwoBytes payment_hash_ref;
26293         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26294         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26295         void* purpose_ptr = untag_ptr(purpose);
26296         CHECK_ACCESS(purpose_ptr);
26297         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
26298         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
26299         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26300         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv);
26301         int64_t ret_ref = tag_ptr(ret_copy, true);
26302         return ret_ref;
26303 }
26304
26305 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) {
26306         LDKThirtyTwoBytes payment_id_ref;
26307         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26308         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26309         LDKThirtyTwoBytes payment_preimage_ref;
26310         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
26311         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
26312         LDKThirtyTwoBytes payment_hash_ref;
26313         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26314         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26315         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
26316         CHECK_ACCESS(fee_paid_msat_ptr);
26317         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
26318         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
26319         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26320         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
26321         int64_t ret_ref = tag_ptr(ret_copy, true);
26322         return ret_ref;
26323 }
26324
26325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
26326         LDKThirtyTwoBytes payment_id_ref;
26327         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26328         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26329         LDKThirtyTwoBytes payment_hash_ref;
26330         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26331         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26332         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26333         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
26334         int64_t ret_ref = tag_ptr(ret_copy, true);
26335         return ret_ref;
26336 }
26337
26338 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) {
26339         LDKThirtyTwoBytes payment_id_ref;
26340         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26341         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26342         LDKThirtyTwoBytes payment_hash_ref;
26343         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26344         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26345         LDKCVec_RouteHopZ path_constr;
26346         path_constr.datalen = (*env)->GetArrayLength(env, path);
26347         if (path_constr.datalen > 0)
26348                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26349         else
26350                 path_constr.data = NULL;
26351         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26352         for (size_t k = 0; k < path_constr.datalen; k++) {
26353                 int64_t path_conv_10 = path_vals[k];
26354                 LDKRouteHop path_conv_10_conv;
26355                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26356                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26357                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26358                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26359                 path_constr.data[k] = path_conv_10_conv;
26360         }
26361         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26362         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26363         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
26364         int64_t ret_ref = tag_ptr(ret_copy, true);
26365         return ret_ref;
26366 }
26367
26368 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) {
26369         LDKThirtyTwoBytes payment_id_ref;
26370         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26371         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26372         LDKThirtyTwoBytes payment_hash_ref;
26373         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26374         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26375         void* network_update_ptr = untag_ptr(network_update);
26376         CHECK_ACCESS(network_update_ptr);
26377         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
26378         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
26379         LDKCVec_RouteHopZ path_constr;
26380         path_constr.datalen = (*env)->GetArrayLength(env, path);
26381         if (path_constr.datalen > 0)
26382                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26383         else
26384                 path_constr.data = NULL;
26385         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26386         for (size_t k = 0; k < path_constr.datalen; k++) {
26387                 int64_t path_conv_10 = path_vals[k];
26388                 LDKRouteHop path_conv_10_conv;
26389                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26390                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26391                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26392                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26393                 path_constr.data[k] = path_conv_10_conv;
26394         }
26395         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26396         void* short_channel_id_ptr = untag_ptr(short_channel_id);
26397         CHECK_ACCESS(short_channel_id_ptr);
26398         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
26399         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
26400         LDKRouteParameters retry_conv;
26401         retry_conv.inner = untag_ptr(retry);
26402         retry_conv.is_owned = ptr_is_owned(retry);
26403         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
26404         retry_conv = RouteParameters_clone(&retry_conv);
26405         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26406         *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);
26407         int64_t ret_ref = tag_ptr(ret_copy, true);
26408         return ret_ref;
26409 }
26410
26411 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) {
26412         LDKThirtyTwoBytes payment_id_ref;
26413         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26414         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26415         LDKThirtyTwoBytes payment_hash_ref;
26416         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26417         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26418         LDKCVec_RouteHopZ path_constr;
26419         path_constr.datalen = (*env)->GetArrayLength(env, path);
26420         if (path_constr.datalen > 0)
26421                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26422         else
26423                 path_constr.data = NULL;
26424         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26425         for (size_t k = 0; k < path_constr.datalen; k++) {
26426                 int64_t path_conv_10 = path_vals[k];
26427                 LDKRouteHop path_conv_10_conv;
26428                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26429                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26430                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26431                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26432                 path_constr.data[k] = path_conv_10_conv;
26433         }
26434         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26435         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26436         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
26437         int64_t ret_ref = tag_ptr(ret_copy, true);
26438         return ret_ref;
26439 }
26440
26441 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) {
26442         LDKThirtyTwoBytes payment_id_ref;
26443         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26444         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26445         LDKThirtyTwoBytes payment_hash_ref;
26446         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26447         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26448         LDKCVec_RouteHopZ path_constr;
26449         path_constr.datalen = (*env)->GetArrayLength(env, path);
26450         if (path_constr.datalen > 0)
26451                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26452         else
26453                 path_constr.data = NULL;
26454         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26455         for (size_t k = 0; k < path_constr.datalen; k++) {
26456                 int64_t path_conv_10 = path_vals[k];
26457                 LDKRouteHop path_conv_10_conv;
26458                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26459                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26460                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26461                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26462                 path_constr.data[k] = path_conv_10_conv;
26463         }
26464         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26465         void* short_channel_id_ptr = untag_ptr(short_channel_id);
26466         CHECK_ACCESS(short_channel_id_ptr);
26467         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
26468         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
26469         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26470         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
26471         int64_t ret_ref = tag_ptr(ret_copy, true);
26472         return ret_ref;
26473 }
26474
26475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
26476         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26477         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
26478         int64_t ret_ref = tag_ptr(ret_copy, true);
26479         return ret_ref;
26480 }
26481
26482 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) {
26483         LDKThirtyTwoBytes intercept_id_ref;
26484         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
26485         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
26486         LDKThirtyTwoBytes payment_hash_ref;
26487         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26488         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26489         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26490         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
26491         int64_t ret_ref = tag_ptr(ret_copy, true);
26492         return ret_ref;
26493 }
26494
26495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
26496         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
26497         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
26498         if (outputs_constr.datalen > 0)
26499                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
26500         else
26501                 outputs_constr.data = NULL;
26502         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
26503         for (size_t b = 0; b < outputs_constr.datalen; b++) {
26504                 int64_t outputs_conv_27 = outputs_vals[b];
26505                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
26506                 CHECK_ACCESS(outputs_conv_27_ptr);
26507                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
26508                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
26509                 outputs_constr.data[b] = outputs_conv_27_conv;
26510         }
26511         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
26512         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26513         *ret_copy = Event_spendable_outputs(outputs_constr);
26514         int64_t ret_ref = tag_ptr(ret_copy, true);
26515         return ret_ref;
26516 }
26517
26518 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) {
26519         LDKThirtyTwoBytes prev_channel_id_ref;
26520         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
26521         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
26522         LDKThirtyTwoBytes next_channel_id_ref;
26523         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
26524         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
26525         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
26526         CHECK_ACCESS(fee_earned_msat_ptr);
26527         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
26528         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
26529         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26530         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
26531         int64_t ret_ref = tag_ptr(ret_copy, true);
26532         return ret_ref;
26533 }
26534
26535 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) {
26536         LDKThirtyTwoBytes channel_id_ref;
26537         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26538         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26539         LDKU128 user_channel_id_ref;
26540         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26541         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26542         LDKPublicKey counterparty_node_id_ref;
26543         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26544         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26545         LDKChannelTypeFeatures channel_type_conv;
26546         channel_type_conv.inner = untag_ptr(channel_type);
26547         channel_type_conv.is_owned = ptr_is_owned(channel_type);
26548         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
26549         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
26550         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26551         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
26552         int64_t ret_ref = tag_ptr(ret_copy, true);
26553         return ret_ref;
26554 }
26555
26556 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) {
26557         LDKThirtyTwoBytes channel_id_ref;
26558         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26559         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26560         LDKU128 user_channel_id_ref;
26561         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26562         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26563         void* reason_ptr = untag_ptr(reason);
26564         CHECK_ACCESS(reason_ptr);
26565         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
26566         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
26567         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26568         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv);
26569         int64_t ret_ref = tag_ptr(ret_copy, true);
26570         return ret_ref;
26571 }
26572
26573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
26574         LDKThirtyTwoBytes channel_id_ref;
26575         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26576         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26577         LDKTransaction transaction_ref;
26578         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
26579         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
26580         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
26581         transaction_ref.data_is_owned = true;
26582         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26583         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
26584         int64_t ret_ref = tag_ptr(ret_copy, true);
26585         return ret_ref;
26586 }
26587
26588 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) {
26589         LDKThirtyTwoBytes temporary_channel_id_ref;
26590         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
26591         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
26592         LDKPublicKey counterparty_node_id_ref;
26593         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26594         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26595         LDKChannelTypeFeatures channel_type_conv;
26596         channel_type_conv.inner = untag_ptr(channel_type);
26597         channel_type_conv.is_owned = ptr_is_owned(channel_type);
26598         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
26599         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
26600         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26601         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
26602         int64_t ret_ref = tag_ptr(ret_copy, true);
26603         return ret_ref;
26604 }
26605
26606 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) {
26607         LDKThirtyTwoBytes prev_channel_id_ref;
26608         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
26609         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
26610         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
26611         CHECK_ACCESS(failed_next_destination_ptr);
26612         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
26613         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
26614         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26615         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
26616         int64_t ret_ref = tag_ptr(ret_copy, true);
26617         return ret_ref;
26618 }
26619
26620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
26621         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
26622         LDKCVec_u8Z ret_var = Event_write(obj_conv);
26623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26625         CVec_u8Z_free(ret_var);
26626         return ret_arr;
26627 }
26628
26629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26630         LDKu8slice ser_ref;
26631         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26632         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26633         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
26634         *ret_conv = Event_read(ser_ref);
26635         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26636         return tag_ptr(ret_conv, true);
26637 }
26638
26639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26640         if (!ptr_is_owned(this_ptr)) return;
26641         void* this_ptr_ptr = untag_ptr(this_ptr);
26642         CHECK_ACCESS(this_ptr_ptr);
26643         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
26644         FREE(untag_ptr(this_ptr));
26645         MessageSendEvent_free(this_ptr_conv);
26646 }
26647
26648 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
26649         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26650         *ret_copy = MessageSendEvent_clone(arg);
26651         int64_t ret_ref = tag_ptr(ret_copy, true);
26652         return ret_ref;
26653 }
26654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26655         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
26656         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
26657         return ret_conv;
26658 }
26659
26660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26661         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
26662         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26663         *ret_copy = MessageSendEvent_clone(orig_conv);
26664         int64_t ret_ref = tag_ptr(ret_copy, true);
26665         return ret_ref;
26666 }
26667
26668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26669         LDKPublicKey node_id_ref;
26670         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26671         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26672         LDKAcceptChannel msg_conv;
26673         msg_conv.inner = untag_ptr(msg);
26674         msg_conv.is_owned = ptr_is_owned(msg);
26675         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26676         msg_conv = AcceptChannel_clone(&msg_conv);
26677         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26678         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
26679         int64_t ret_ref = tag_ptr(ret_copy, true);
26680         return ret_ref;
26681 }
26682
26683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26684         LDKPublicKey node_id_ref;
26685         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26686         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26687         LDKOpenChannel msg_conv;
26688         msg_conv.inner = untag_ptr(msg);
26689         msg_conv.is_owned = ptr_is_owned(msg);
26690         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26691         msg_conv = OpenChannel_clone(&msg_conv);
26692         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26693         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
26694         int64_t ret_ref = tag_ptr(ret_copy, true);
26695         return ret_ref;
26696 }
26697
26698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26699         LDKPublicKey node_id_ref;
26700         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26701         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26702         LDKFundingCreated msg_conv;
26703         msg_conv.inner = untag_ptr(msg);
26704         msg_conv.is_owned = ptr_is_owned(msg);
26705         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26706         msg_conv = FundingCreated_clone(&msg_conv);
26707         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26708         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
26709         int64_t ret_ref = tag_ptr(ret_copy, true);
26710         return ret_ref;
26711 }
26712
26713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26714         LDKPublicKey node_id_ref;
26715         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26716         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26717         LDKFundingSigned msg_conv;
26718         msg_conv.inner = untag_ptr(msg);
26719         msg_conv.is_owned = ptr_is_owned(msg);
26720         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26721         msg_conv = FundingSigned_clone(&msg_conv);
26722         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26723         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
26724         int64_t ret_ref = tag_ptr(ret_copy, true);
26725         return ret_ref;
26726 }
26727
26728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26729         LDKPublicKey node_id_ref;
26730         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26731         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26732         LDKChannelReady msg_conv;
26733         msg_conv.inner = untag_ptr(msg);
26734         msg_conv.is_owned = ptr_is_owned(msg);
26735         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26736         msg_conv = ChannelReady_clone(&msg_conv);
26737         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26738         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
26739         int64_t ret_ref = tag_ptr(ret_copy, true);
26740         return ret_ref;
26741 }
26742
26743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26744         LDKPublicKey node_id_ref;
26745         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26746         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26747         LDKAnnouncementSignatures msg_conv;
26748         msg_conv.inner = untag_ptr(msg);
26749         msg_conv.is_owned = ptr_is_owned(msg);
26750         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26751         msg_conv = AnnouncementSignatures_clone(&msg_conv);
26752         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26753         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
26754         int64_t ret_ref = tag_ptr(ret_copy, true);
26755         return ret_ref;
26756 }
26757
26758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
26759         LDKPublicKey node_id_ref;
26760         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26761         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26762         LDKCommitmentUpdate updates_conv;
26763         updates_conv.inner = untag_ptr(updates);
26764         updates_conv.is_owned = ptr_is_owned(updates);
26765         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26766         updates_conv = CommitmentUpdate_clone(&updates_conv);
26767         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26768         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
26769         int64_t ret_ref = tag_ptr(ret_copy, true);
26770         return ret_ref;
26771 }
26772
26773 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) {
26774         LDKPublicKey node_id_ref;
26775         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26776         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26777         LDKRevokeAndACK msg_conv;
26778         msg_conv.inner = untag_ptr(msg);
26779         msg_conv.is_owned = ptr_is_owned(msg);
26780         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26781         msg_conv = RevokeAndACK_clone(&msg_conv);
26782         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26783         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
26784         int64_t ret_ref = tag_ptr(ret_copy, true);
26785         return ret_ref;
26786 }
26787
26788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26789         LDKPublicKey node_id_ref;
26790         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26791         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26792         LDKClosingSigned msg_conv;
26793         msg_conv.inner = untag_ptr(msg);
26794         msg_conv.is_owned = ptr_is_owned(msg);
26795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26796         msg_conv = ClosingSigned_clone(&msg_conv);
26797         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26798         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
26799         int64_t ret_ref = tag_ptr(ret_copy, true);
26800         return ret_ref;
26801 }
26802
26803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26804         LDKPublicKey node_id_ref;
26805         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26806         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26807         LDKShutdown msg_conv;
26808         msg_conv.inner = untag_ptr(msg);
26809         msg_conv.is_owned = ptr_is_owned(msg);
26810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26811         msg_conv = Shutdown_clone(&msg_conv);
26812         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26813         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
26814         int64_t ret_ref = tag_ptr(ret_copy, true);
26815         return ret_ref;
26816 }
26817
26818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26819         LDKPublicKey node_id_ref;
26820         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26821         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26822         LDKChannelReestablish msg_conv;
26823         msg_conv.inner = untag_ptr(msg);
26824         msg_conv.is_owned = ptr_is_owned(msg);
26825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26826         msg_conv = ChannelReestablish_clone(&msg_conv);
26827         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26828         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
26829         int64_t ret_ref = tag_ptr(ret_copy, true);
26830         return ret_ref;
26831 }
26832
26833 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) {
26834         LDKPublicKey node_id_ref;
26835         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26836         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26837         LDKChannelAnnouncement msg_conv;
26838         msg_conv.inner = untag_ptr(msg);
26839         msg_conv.is_owned = ptr_is_owned(msg);
26840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26841         msg_conv = ChannelAnnouncement_clone(&msg_conv);
26842         LDKChannelUpdate update_msg_conv;
26843         update_msg_conv.inner = untag_ptr(update_msg);
26844         update_msg_conv.is_owned = ptr_is_owned(update_msg);
26845         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
26846         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
26847         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26848         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
26849         int64_t ret_ref = tag_ptr(ret_copy, true);
26850         return ret_ref;
26851 }
26852
26853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
26854         LDKChannelAnnouncement msg_conv;
26855         msg_conv.inner = untag_ptr(msg);
26856         msg_conv.is_owned = ptr_is_owned(msg);
26857         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26858         msg_conv = ChannelAnnouncement_clone(&msg_conv);
26859         LDKChannelUpdate update_msg_conv;
26860         update_msg_conv.inner = untag_ptr(update_msg);
26861         update_msg_conv.is_owned = ptr_is_owned(update_msg);
26862         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
26863         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
26864         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26865         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
26866         int64_t ret_ref = tag_ptr(ret_copy, true);
26867         return ret_ref;
26868 }
26869
26870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
26871         LDKChannelUpdate msg_conv;
26872         msg_conv.inner = untag_ptr(msg);
26873         msg_conv.is_owned = ptr_is_owned(msg);
26874         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26875         msg_conv = ChannelUpdate_clone(&msg_conv);
26876         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26877         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
26878         int64_t ret_ref = tag_ptr(ret_copy, true);
26879         return ret_ref;
26880 }
26881
26882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26883         LDKPublicKey node_id_ref;
26884         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26885         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26886         LDKChannelUpdate msg_conv;
26887         msg_conv.inner = untag_ptr(msg);
26888         msg_conv.is_owned = ptr_is_owned(msg);
26889         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26890         msg_conv = ChannelUpdate_clone(&msg_conv);
26891         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26892         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
26893         int64_t ret_ref = tag_ptr(ret_copy, true);
26894         return ret_ref;
26895 }
26896
26897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
26898         LDKPublicKey node_id_ref;
26899         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26900         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26901         void* action_ptr = untag_ptr(action);
26902         CHECK_ACCESS(action_ptr);
26903         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
26904         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
26905         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26906         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
26907         int64_t ret_ref = tag_ptr(ret_copy, true);
26908         return ret_ref;
26909 }
26910
26911 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) {
26912         LDKPublicKey node_id_ref;
26913         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26914         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26915         LDKQueryChannelRange msg_conv;
26916         msg_conv.inner = untag_ptr(msg);
26917         msg_conv.is_owned = ptr_is_owned(msg);
26918         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26919         msg_conv = QueryChannelRange_clone(&msg_conv);
26920         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26921         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
26922         int64_t ret_ref = tag_ptr(ret_copy, true);
26923         return ret_ref;
26924 }
26925
26926 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) {
26927         LDKPublicKey node_id_ref;
26928         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26929         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26930         LDKQueryShortChannelIds msg_conv;
26931         msg_conv.inner = untag_ptr(msg);
26932         msg_conv.is_owned = ptr_is_owned(msg);
26933         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26934         msg_conv = QueryShortChannelIds_clone(&msg_conv);
26935         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26936         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
26937         int64_t ret_ref = tag_ptr(ret_copy, true);
26938         return ret_ref;
26939 }
26940
26941 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) {
26942         LDKPublicKey node_id_ref;
26943         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26944         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26945         LDKReplyChannelRange msg_conv;
26946         msg_conv.inner = untag_ptr(msg);
26947         msg_conv.is_owned = ptr_is_owned(msg);
26948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26949         msg_conv = ReplyChannelRange_clone(&msg_conv);
26950         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26951         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
26952         int64_t ret_ref = tag_ptr(ret_copy, true);
26953         return ret_ref;
26954 }
26955
26956 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) {
26957         LDKPublicKey node_id_ref;
26958         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26959         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26960         LDKGossipTimestampFilter msg_conv;
26961         msg_conv.inner = untag_ptr(msg);
26962         msg_conv.is_owned = ptr_is_owned(msg);
26963         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26964         msg_conv = GossipTimestampFilter_clone(&msg_conv);
26965         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26966         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
26967         int64_t ret_ref = tag_ptr(ret_copy, true);
26968         return ret_ref;
26969 }
26970
26971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26972         if (!ptr_is_owned(this_ptr)) return;
26973         void* this_ptr_ptr = untag_ptr(this_ptr);
26974         CHECK_ACCESS(this_ptr_ptr);
26975         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
26976         FREE(untag_ptr(this_ptr));
26977         MessageSendEventsProvider_free(this_ptr_conv);
26978 }
26979
26980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26981         if (!ptr_is_owned(this_ptr)) return;
26982         void* this_ptr_ptr = untag_ptr(this_ptr);
26983         CHECK_ACCESS(this_ptr_ptr);
26984         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
26985         FREE(untag_ptr(this_ptr));
26986         OnionMessageProvider_free(this_ptr_conv);
26987 }
26988
26989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26990         if (!ptr_is_owned(this_ptr)) return;
26991         void* this_ptr_ptr = untag_ptr(this_ptr);
26992         CHECK_ACCESS(this_ptr_ptr);
26993         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
26994         FREE(untag_ptr(this_ptr));
26995         EventsProvider_free(this_ptr_conv);
26996 }
26997
26998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26999         if (!ptr_is_owned(this_ptr)) return;
27000         void* this_ptr_ptr = untag_ptr(this_ptr);
27001         CHECK_ACCESS(this_ptr_ptr);
27002         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
27003         FREE(untag_ptr(this_ptr));
27004         EventHandler_free(this_ptr_conv);
27005 }
27006
27007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27008         if (!ptr_is_owned(this_ptr)) return;
27009         void* this_ptr_ptr = untag_ptr(this_ptr);
27010         CHECK_ACCESS(this_ptr_ptr);
27011         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
27012         FREE(untag_ptr(this_ptr));
27013         APIError_free(this_ptr_conv);
27014 }
27015
27016 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
27017         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27018         *ret_copy = APIError_clone(arg);
27019         int64_t ret_ref = tag_ptr(ret_copy, true);
27020         return ret_ref;
27021 }
27022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27023         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
27024         int64_t ret_conv = APIError_clone_ptr(arg_conv);
27025         return ret_conv;
27026 }
27027
27028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27029         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
27030         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27031         *ret_copy = APIError_clone(orig_conv);
27032         int64_t ret_ref = tag_ptr(ret_copy, true);
27033         return ret_ref;
27034 }
27035
27036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
27037         LDKStr err_conv = java_to_owned_str(env, err);
27038         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27039         *ret_copy = APIError_apimisuse_error(err_conv);
27040         int64_t ret_ref = tag_ptr(ret_copy, true);
27041         return ret_ref;
27042 }
27043
27044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
27045         LDKStr err_conv = java_to_owned_str(env, err);
27046         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27047         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
27048         int64_t ret_ref = tag_ptr(ret_copy, true);
27049         return ret_ref;
27050 }
27051
27052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1invalid_1route(JNIEnv *env, jclass clz, jstring err) {
27053         LDKStr err_conv = java_to_owned_str(env, err);
27054         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27055         *ret_copy = APIError_invalid_route(err_conv);
27056         int64_t ret_ref = tag_ptr(ret_copy, true);
27057         return ret_ref;
27058 }
27059
27060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
27061         LDKStr err_conv = java_to_owned_str(env, err);
27062         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27063         *ret_copy = APIError_channel_unavailable(err_conv);
27064         int64_t ret_ref = tag_ptr(ret_copy, true);
27065         return ret_ref;
27066 }
27067
27068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
27069         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27070         *ret_copy = APIError_monitor_update_in_progress();
27071         int64_t ret_ref = tag_ptr(ret_copy, true);
27072         return ret_ref;
27073 }
27074
27075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
27076         LDKShutdownScript script_conv;
27077         script_conv.inner = untag_ptr(script);
27078         script_conv.is_owned = ptr_is_owned(script);
27079         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
27080         script_conv = ShutdownScript_clone(&script_conv);
27081         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27082         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
27083         int64_t ret_ref = tag_ptr(ret_copy, true);
27084         return ret_ref;
27085 }
27086
27087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27088         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
27089         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
27090         jboolean ret_conv = APIError_eq(a_conv, b_conv);
27091         return ret_conv;
27092 }
27093
27094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27095         LDKBigSize this_obj_conv;
27096         this_obj_conv.inner = untag_ptr(this_obj);
27097         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27099         BigSize_free(this_obj_conv);
27100 }
27101
27102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27103         LDKBigSize this_ptr_conv;
27104         this_ptr_conv.inner = untag_ptr(this_ptr);
27105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27107         this_ptr_conv.is_owned = false;
27108         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
27109         return ret_conv;
27110 }
27111
27112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27113         LDKBigSize this_ptr_conv;
27114         this_ptr_conv.inner = untag_ptr(this_ptr);
27115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27117         this_ptr_conv.is_owned = false;
27118         BigSize_set_a(&this_ptr_conv, val);
27119 }
27120
27121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
27122         LDKBigSize ret_var = BigSize_new(a_arg);
27123         int64_t ret_ref = 0;
27124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27125         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27126         return ret_ref;
27127 }
27128
27129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27130         LDKHostname this_obj_conv;
27131         this_obj_conv.inner = untag_ptr(this_obj);
27132         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27134         Hostname_free(this_obj_conv);
27135 }
27136
27137 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
27138         LDKHostname ret_var = Hostname_clone(arg);
27139         int64_t ret_ref = 0;
27140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27142         return ret_ref;
27143 }
27144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27145         LDKHostname arg_conv;
27146         arg_conv.inner = untag_ptr(arg);
27147         arg_conv.is_owned = ptr_is_owned(arg);
27148         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27149         arg_conv.is_owned = false;
27150         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
27151         return ret_conv;
27152 }
27153
27154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27155         LDKHostname orig_conv;
27156         orig_conv.inner = untag_ptr(orig);
27157         orig_conv.is_owned = ptr_is_owned(orig);
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27159         orig_conv.is_owned = false;
27160         LDKHostname ret_var = Hostname_clone(&orig_conv);
27161         int64_t ret_ref = 0;
27162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27163         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27164         return ret_ref;
27165 }
27166
27167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27168         LDKHostname a_conv;
27169         a_conv.inner = untag_ptr(a);
27170         a_conv.is_owned = ptr_is_owned(a);
27171         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27172         a_conv.is_owned = false;
27173         LDKHostname b_conv;
27174         b_conv.inner = untag_ptr(b);
27175         b_conv.is_owned = ptr_is_owned(b);
27176         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27177         b_conv.is_owned = false;
27178         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
27179         return ret_conv;
27180 }
27181
27182 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
27183         LDKHostname this_arg_conv;
27184         this_arg_conv.inner = untag_ptr(this_arg);
27185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27187         this_arg_conv.is_owned = false;
27188         int8_t ret_conv = Hostname_len(&this_arg_conv);
27189         return ret_conv;
27190 }
27191
27192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
27193         LDKu8slice msg_ref;
27194         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27195         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27196         unsigned char sk_arr[32];
27197         CHECK((*env)->GetArrayLength(env, sk) == 32);
27198         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
27199         unsigned char (*sk_ref)[32] = &sk_arr;
27200         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
27201         *ret_conv = sign(msg_ref, sk_ref);
27202         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27203         return tag_ptr(ret_conv, true);
27204 }
27205
27206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
27207         LDKu8slice msg_ref;
27208         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27209         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27210         LDKStr sig_conv = java_to_owned_str(env, sig);
27211         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27212         *ret_conv = recover_pk(msg_ref, sig_conv);
27213         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27214         return tag_ptr(ret_conv, true);
27215 }
27216
27217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
27218         LDKu8slice msg_ref;
27219         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27220         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27221         LDKStr sig_conv = java_to_owned_str(env, sig);
27222         LDKPublicKey pk_ref;
27223         CHECK((*env)->GetArrayLength(env, pk) == 33);
27224         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
27225         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
27226         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27227         return ret_conv;
27228 }
27229
27230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
27231         LDKu8slice hrp_bytes_ref;
27232         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
27233         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
27234         LDKCVec_U5Z data_without_signature_constr;
27235         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
27236         if (data_without_signature_constr.datalen > 0)
27237                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
27238         else
27239                 data_without_signature_constr.data = NULL;
27240         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
27241         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
27242                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
27243                 
27244                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
27245         }
27246         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
27247         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
27248         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27249         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27250         CVec_u8Z_free(ret_var);
27251         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
27252         return ret_arr;
27253 }
27254
27255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27256         if (!ptr_is_owned(this_ptr)) return;
27257         void* this_ptr_ptr = untag_ptr(this_ptr);
27258         CHECK_ACCESS(this_ptr_ptr);
27259         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
27260         FREE(untag_ptr(this_ptr));
27261         Persister_free(this_ptr_conv);
27262 }
27263
27264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27265         LDKPrintableString this_obj_conv;
27266         this_obj_conv.inner = untag_ptr(this_obj);
27267         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27269         PrintableString_free(this_obj_conv);
27270 }
27271
27272 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_PrintableString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27273         LDKPrintableString this_ptr_conv;
27274         this_ptr_conv.inner = untag_ptr(this_ptr);
27275         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27277         this_ptr_conv.is_owned = false;
27278         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
27279         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27280         Str_free(ret_str);
27281         return ret_conv;
27282 }
27283
27284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27285         LDKPrintableString this_ptr_conv;
27286         this_ptr_conv.inner = untag_ptr(this_ptr);
27287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27289         this_ptr_conv.is_owned = false;
27290         LDKStr val_conv = java_to_owned_str(env, val);
27291         PrintableString_set_a(&this_ptr_conv, val_conv);
27292 }
27293
27294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrintableString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27295         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27296         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
27297         int64_t ret_ref = 0;
27298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27299         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27300         return ret_ref;
27301 }
27302
27303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27304         if (!ptr_is_owned(this_ptr)) return;
27305         void* this_ptr_ptr = untag_ptr(this_ptr);
27306         CHECK_ACCESS(this_ptr_ptr);
27307         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
27308         FREE(untag_ptr(this_ptr));
27309         FutureCallback_free(this_ptr_conv);
27310 }
27311
27312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27313         LDKFuture this_obj_conv;
27314         this_obj_conv.inner = untag_ptr(this_obj);
27315         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27317         Future_free(this_obj_conv);
27318 }
27319
27320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
27321         LDKFuture this_arg_conv;
27322         this_arg_conv.inner = untag_ptr(this_arg);
27323         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27325         this_arg_conv.is_owned = false;
27326         void* callback_ptr = untag_ptr(callback);
27327         CHECK_ACCESS(callback_ptr);
27328         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
27329         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
27330                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27331                 LDKFutureCallback_JCalls_cloned(&callback_conv);
27332         }
27333         Future_register_callback_fn(&this_arg_conv, callback_conv);
27334 }
27335
27336 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27337         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
27338         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
27339         return ret_conv;
27340 }
27341
27342 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
27343         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
27344         return ret_conv;
27345 }
27346
27347 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
27348         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
27349         return ret_conv;
27350 }
27351
27352 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
27353         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
27354         return ret_conv;
27355 }
27356
27357 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
27358         jclass ret_conv = LDKLevel_to_java(env, Level_info());
27359         return ret_conv;
27360 }
27361
27362 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
27363         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
27364         return ret_conv;
27365 }
27366
27367 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
27368         jclass ret_conv = LDKLevel_to_java(env, Level_error());
27369         return ret_conv;
27370 }
27371
27372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27373         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
27374         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
27375         jboolean ret_conv = Level_eq(a_conv, b_conv);
27376         return ret_conv;
27377 }
27378
27379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
27380         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
27381         int64_t ret_conv = Level_hash(o_conv);
27382         return ret_conv;
27383 }
27384
27385 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
27386         jclass ret_conv = LDKLevel_to_java(env, Level_max());
27387         return ret_conv;
27388 }
27389
27390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27391         LDKRecord this_obj_conv;
27392         this_obj_conv.inner = untag_ptr(this_obj);
27393         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27395         Record_free(this_obj_conv);
27396 }
27397
27398 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
27399         LDKRecord this_ptr_conv;
27400         this_ptr_conv.inner = untag_ptr(this_ptr);
27401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27403         this_ptr_conv.is_owned = false;
27404         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
27405         return ret_conv;
27406 }
27407
27408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27409         LDKRecord this_ptr_conv;
27410         this_ptr_conv.inner = untag_ptr(this_ptr);
27411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27413         this_ptr_conv.is_owned = false;
27414         LDKLevel val_conv = LDKLevel_from_java(env, val);
27415         Record_set_level(&this_ptr_conv, val_conv);
27416 }
27417
27418 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
27419         LDKRecord this_ptr_conv;
27420         this_ptr_conv.inner = untag_ptr(this_ptr);
27421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27423         this_ptr_conv.is_owned = false;
27424         LDKStr ret_str = Record_get_args(&this_ptr_conv);
27425         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27426         Str_free(ret_str);
27427         return ret_conv;
27428 }
27429
27430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27431         LDKRecord this_ptr_conv;
27432         this_ptr_conv.inner = untag_ptr(this_ptr);
27433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27435         this_ptr_conv.is_owned = false;
27436         LDKStr val_conv = java_to_owned_str(env, val);
27437         Record_set_args(&this_ptr_conv, val_conv);
27438 }
27439
27440 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
27441         LDKRecord this_ptr_conv;
27442         this_ptr_conv.inner = untag_ptr(this_ptr);
27443         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27445         this_ptr_conv.is_owned = false;
27446         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
27447         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27448         Str_free(ret_str);
27449         return ret_conv;
27450 }
27451
27452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27453         LDKRecord this_ptr_conv;
27454         this_ptr_conv.inner = untag_ptr(this_ptr);
27455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27457         this_ptr_conv.is_owned = false;
27458         LDKStr val_conv = java_to_owned_str(env, val);
27459         Record_set_module_path(&this_ptr_conv, val_conv);
27460 }
27461
27462 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
27463         LDKRecord this_ptr_conv;
27464         this_ptr_conv.inner = untag_ptr(this_ptr);
27465         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27467         this_ptr_conv.is_owned = false;
27468         LDKStr ret_str = Record_get_file(&this_ptr_conv);
27469         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27470         Str_free(ret_str);
27471         return ret_conv;
27472 }
27473
27474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27475         LDKRecord this_ptr_conv;
27476         this_ptr_conv.inner = untag_ptr(this_ptr);
27477         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27479         this_ptr_conv.is_owned = false;
27480         LDKStr val_conv = java_to_owned_str(env, val);
27481         Record_set_file(&this_ptr_conv, val_conv);
27482 }
27483
27484 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
27485         LDKRecord this_ptr_conv;
27486         this_ptr_conv.inner = untag_ptr(this_ptr);
27487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27489         this_ptr_conv.is_owned = false;
27490         int32_t ret_conv = Record_get_line(&this_ptr_conv);
27491         return ret_conv;
27492 }
27493
27494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27495         LDKRecord this_ptr_conv;
27496         this_ptr_conv.inner = untag_ptr(this_ptr);
27497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27499         this_ptr_conv.is_owned = false;
27500         Record_set_line(&this_ptr_conv, val);
27501 }
27502
27503 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
27504         LDKRecord ret_var = Record_clone(arg);
27505         int64_t ret_ref = 0;
27506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27508         return ret_ref;
27509 }
27510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27511         LDKRecord arg_conv;
27512         arg_conv.inner = untag_ptr(arg);
27513         arg_conv.is_owned = ptr_is_owned(arg);
27514         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27515         arg_conv.is_owned = false;
27516         int64_t ret_conv = Record_clone_ptr(&arg_conv);
27517         return ret_conv;
27518 }
27519
27520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27521         LDKRecord orig_conv;
27522         orig_conv.inner = untag_ptr(orig);
27523         orig_conv.is_owned = ptr_is_owned(orig);
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27525         orig_conv.is_owned = false;
27526         LDKRecord ret_var = Record_clone(&orig_conv);
27527         int64_t ret_ref = 0;
27528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27530         return ret_ref;
27531 }
27532
27533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27534         if (!ptr_is_owned(this_ptr)) return;
27535         void* this_ptr_ptr = untag_ptr(this_ptr);
27536         CHECK_ACCESS(this_ptr_ptr);
27537         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
27538         FREE(untag_ptr(this_ptr));
27539         Logger_free(this_ptr_conv);
27540 }
27541
27542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27543         LDKChannelHandshakeConfig this_obj_conv;
27544         this_obj_conv.inner = untag_ptr(this_obj);
27545         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27547         ChannelHandshakeConfig_free(this_obj_conv);
27548 }
27549
27550 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27551         LDKChannelHandshakeConfig this_ptr_conv;
27552         this_ptr_conv.inner = untag_ptr(this_ptr);
27553         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27555         this_ptr_conv.is_owned = false;
27556         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
27557         return ret_conv;
27558 }
27559
27560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27561         LDKChannelHandshakeConfig this_ptr_conv;
27562         this_ptr_conv.inner = untag_ptr(this_ptr);
27563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27565         this_ptr_conv.is_owned = false;
27566         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
27567 }
27568
27569 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27570         LDKChannelHandshakeConfig this_ptr_conv;
27571         this_ptr_conv.inner = untag_ptr(this_ptr);
27572         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27574         this_ptr_conv.is_owned = false;
27575         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
27576         return ret_conv;
27577 }
27578
27579 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) {
27580         LDKChannelHandshakeConfig this_ptr_conv;
27581         this_ptr_conv.inner = untag_ptr(this_ptr);
27582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27584         this_ptr_conv.is_owned = false;
27585         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
27586 }
27587
27588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27589         LDKChannelHandshakeConfig this_ptr_conv;
27590         this_ptr_conv.inner = untag_ptr(this_ptr);
27591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27593         this_ptr_conv.is_owned = false;
27594         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
27595         return ret_conv;
27596 }
27597
27598 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) {
27599         LDKChannelHandshakeConfig this_ptr_conv;
27600         this_ptr_conv.inner = untag_ptr(this_ptr);
27601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27603         this_ptr_conv.is_owned = false;
27604         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
27605 }
27606
27607 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) {
27608         LDKChannelHandshakeConfig this_ptr_conv;
27609         this_ptr_conv.inner = untag_ptr(this_ptr);
27610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27612         this_ptr_conv.is_owned = false;
27613         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
27614         return ret_conv;
27615 }
27616
27617 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) {
27618         LDKChannelHandshakeConfig this_ptr_conv;
27619         this_ptr_conv.inner = untag_ptr(this_ptr);
27620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27622         this_ptr_conv.is_owned = false;
27623         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
27624 }
27625
27626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
27627         LDKChannelHandshakeConfig this_ptr_conv;
27628         this_ptr_conv.inner = untag_ptr(this_ptr);
27629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27631         this_ptr_conv.is_owned = false;
27632         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
27633         return ret_conv;
27634 }
27635
27636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27637         LDKChannelHandshakeConfig this_ptr_conv;
27638         this_ptr_conv.inner = untag_ptr(this_ptr);
27639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27641         this_ptr_conv.is_owned = false;
27642         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
27643 }
27644
27645 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
27646         LDKChannelHandshakeConfig this_ptr_conv;
27647         this_ptr_conv.inner = untag_ptr(this_ptr);
27648         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27650         this_ptr_conv.is_owned = false;
27651         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
27652         return ret_conv;
27653 }
27654
27655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27656         LDKChannelHandshakeConfig this_ptr_conv;
27657         this_ptr_conv.inner = untag_ptr(this_ptr);
27658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27660         this_ptr_conv.is_owned = false;
27661         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
27662 }
27663
27664 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27665         LDKChannelHandshakeConfig this_ptr_conv;
27666         this_ptr_conv.inner = untag_ptr(this_ptr);
27667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27669         this_ptr_conv.is_owned = false;
27670         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
27671         return ret_conv;
27672 }
27673
27674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27675         LDKChannelHandshakeConfig this_ptr_conv;
27676         this_ptr_conv.inner = untag_ptr(this_ptr);
27677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27679         this_ptr_conv.is_owned = false;
27680         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
27681 }
27682
27683 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27684         LDKChannelHandshakeConfig this_ptr_conv;
27685         this_ptr_conv.inner = untag_ptr(this_ptr);
27686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27688         this_ptr_conv.is_owned = false;
27689         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
27690         return ret_conv;
27691 }
27692
27693 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) {
27694         LDKChannelHandshakeConfig this_ptr_conv;
27695         this_ptr_conv.inner = untag_ptr(this_ptr);
27696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27698         this_ptr_conv.is_owned = false;
27699         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
27700 }
27701
27702 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) {
27703         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);
27704         int64_t ret_ref = 0;
27705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27707         return ret_ref;
27708 }
27709
27710 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
27711         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
27712         int64_t ret_ref = 0;
27713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27715         return ret_ref;
27716 }
27717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27718         LDKChannelHandshakeConfig arg_conv;
27719         arg_conv.inner = untag_ptr(arg);
27720         arg_conv.is_owned = ptr_is_owned(arg);
27721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27722         arg_conv.is_owned = false;
27723         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
27724         return ret_conv;
27725 }
27726
27727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27728         LDKChannelHandshakeConfig orig_conv;
27729         orig_conv.inner = untag_ptr(orig);
27730         orig_conv.is_owned = ptr_is_owned(orig);
27731         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27732         orig_conv.is_owned = false;
27733         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
27734         int64_t ret_ref = 0;
27735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27736         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27737         return ret_ref;
27738 }
27739
27740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
27741         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
27742         int64_t ret_ref = 0;
27743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27745         return ret_ref;
27746 }
27747
27748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27749         LDKChannelHandshakeLimits this_obj_conv;
27750         this_obj_conv.inner = untag_ptr(this_obj);
27751         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27753         ChannelHandshakeLimits_free(this_obj_conv);
27754 }
27755
27756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27757         LDKChannelHandshakeLimits this_ptr_conv;
27758         this_ptr_conv.inner = untag_ptr(this_ptr);
27759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27761         this_ptr_conv.is_owned = false;
27762         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
27763         return ret_conv;
27764 }
27765
27766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27767         LDKChannelHandshakeLimits this_ptr_conv;
27768         this_ptr_conv.inner = untag_ptr(this_ptr);
27769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27771         this_ptr_conv.is_owned = false;
27772         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
27773 }
27774
27775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27776         LDKChannelHandshakeLimits this_ptr_conv;
27777         this_ptr_conv.inner = untag_ptr(this_ptr);
27778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27780         this_ptr_conv.is_owned = false;
27781         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
27782         return ret_conv;
27783 }
27784
27785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27786         LDKChannelHandshakeLimits this_ptr_conv;
27787         this_ptr_conv.inner = untag_ptr(this_ptr);
27788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27790         this_ptr_conv.is_owned = false;
27791         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
27792 }
27793
27794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27795         LDKChannelHandshakeLimits this_ptr_conv;
27796         this_ptr_conv.inner = untag_ptr(this_ptr);
27797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27799         this_ptr_conv.is_owned = false;
27800         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
27801         return ret_conv;
27802 }
27803
27804 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) {
27805         LDKChannelHandshakeLimits this_ptr_conv;
27806         this_ptr_conv.inner = untag_ptr(this_ptr);
27807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27809         this_ptr_conv.is_owned = false;
27810         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
27811 }
27812
27813 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) {
27814         LDKChannelHandshakeLimits this_ptr_conv;
27815         this_ptr_conv.inner = untag_ptr(this_ptr);
27816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27818         this_ptr_conv.is_owned = false;
27819         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
27820         return ret_conv;
27821 }
27822
27823 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) {
27824         LDKChannelHandshakeLimits this_ptr_conv;
27825         this_ptr_conv.inner = untag_ptr(this_ptr);
27826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27828         this_ptr_conv.is_owned = false;
27829         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
27830 }
27831
27832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27833         LDKChannelHandshakeLimits this_ptr_conv;
27834         this_ptr_conv.inner = untag_ptr(this_ptr);
27835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27837         this_ptr_conv.is_owned = false;
27838         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
27839         return ret_conv;
27840 }
27841
27842 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) {
27843         LDKChannelHandshakeLimits this_ptr_conv;
27844         this_ptr_conv.inner = untag_ptr(this_ptr);
27845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27847         this_ptr_conv.is_owned = false;
27848         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
27849 }
27850
27851 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
27852         LDKChannelHandshakeLimits this_ptr_conv;
27853         this_ptr_conv.inner = untag_ptr(this_ptr);
27854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27856         this_ptr_conv.is_owned = false;
27857         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
27858         return ret_conv;
27859 }
27860
27861 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) {
27862         LDKChannelHandshakeLimits this_ptr_conv;
27863         this_ptr_conv.inner = untag_ptr(this_ptr);
27864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27866         this_ptr_conv.is_owned = false;
27867         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
27868 }
27869
27870 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27871         LDKChannelHandshakeLimits this_ptr_conv;
27872         this_ptr_conv.inner = untag_ptr(this_ptr);
27873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27875         this_ptr_conv.is_owned = false;
27876         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
27877         return ret_conv;
27878 }
27879
27880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27881         LDKChannelHandshakeLimits this_ptr_conv;
27882         this_ptr_conv.inner = untag_ptr(this_ptr);
27883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27885         this_ptr_conv.is_owned = false;
27886         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
27887 }
27888
27889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
27890         LDKChannelHandshakeLimits this_ptr_conv;
27891         this_ptr_conv.inner = untag_ptr(this_ptr);
27892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27894         this_ptr_conv.is_owned = false;
27895         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
27896         return ret_conv;
27897 }
27898
27899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27900         LDKChannelHandshakeLimits this_ptr_conv;
27901         this_ptr_conv.inner = untag_ptr(this_ptr);
27902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27904         this_ptr_conv.is_owned = false;
27905         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
27906 }
27907
27908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
27909         LDKChannelHandshakeLimits this_ptr_conv;
27910         this_ptr_conv.inner = untag_ptr(this_ptr);
27911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27913         this_ptr_conv.is_owned = false;
27914         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
27915         return ret_conv;
27916 }
27917
27918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27919         LDKChannelHandshakeLimits this_ptr_conv;
27920         this_ptr_conv.inner = untag_ptr(this_ptr);
27921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27923         this_ptr_conv.is_owned = false;
27924         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
27925 }
27926
27927 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27928         LDKChannelHandshakeLimits this_ptr_conv;
27929         this_ptr_conv.inner = untag_ptr(this_ptr);
27930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27932         this_ptr_conv.is_owned = false;
27933         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
27934         return ret_conv;
27935 }
27936
27937 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) {
27938         LDKChannelHandshakeLimits this_ptr_conv;
27939         this_ptr_conv.inner = untag_ptr(this_ptr);
27940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27942         this_ptr_conv.is_owned = false;
27943         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
27944 }
27945
27946 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) {
27947         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);
27948         int64_t ret_ref = 0;
27949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27951         return ret_ref;
27952 }
27953
27954 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
27955         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
27956         int64_t ret_ref = 0;
27957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27959         return ret_ref;
27960 }
27961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27962         LDKChannelHandshakeLimits arg_conv;
27963         arg_conv.inner = untag_ptr(arg);
27964         arg_conv.is_owned = ptr_is_owned(arg);
27965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27966         arg_conv.is_owned = false;
27967         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
27968         return ret_conv;
27969 }
27970
27971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27972         LDKChannelHandshakeLimits orig_conv;
27973         orig_conv.inner = untag_ptr(orig);
27974         orig_conv.is_owned = ptr_is_owned(orig);
27975         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27976         orig_conv.is_owned = false;
27977         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
27978         int64_t ret_ref = 0;
27979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27981         return ret_ref;
27982 }
27983
27984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
27985         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
27986         int64_t ret_ref = 0;
27987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27989         return ret_ref;
27990 }
27991
27992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27993         LDKChannelConfig this_obj_conv;
27994         this_obj_conv.inner = untag_ptr(this_obj);
27995         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27997         ChannelConfig_free(this_obj_conv);
27998 }
27999
28000 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28001         LDKChannelConfig this_ptr_conv;
28002         this_ptr_conv.inner = untag_ptr(this_ptr);
28003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28005         this_ptr_conv.is_owned = false;
28006         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
28007         return ret_conv;
28008 }
28009
28010 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) {
28011         LDKChannelConfig this_ptr_conv;
28012         this_ptr_conv.inner = untag_ptr(this_ptr);
28013         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28015         this_ptr_conv.is_owned = false;
28016         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
28017 }
28018
28019 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28020         LDKChannelConfig this_ptr_conv;
28021         this_ptr_conv.inner = untag_ptr(this_ptr);
28022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28024         this_ptr_conv.is_owned = false;
28025         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
28026         return ret_conv;
28027 }
28028
28029 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) {
28030         LDKChannelConfig this_ptr_conv;
28031         this_ptr_conv.inner = untag_ptr(this_ptr);
28032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28034         this_ptr_conv.is_owned = false;
28035         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
28036 }
28037
28038 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28039         LDKChannelConfig this_ptr_conv;
28040         this_ptr_conv.inner = untag_ptr(this_ptr);
28041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28043         this_ptr_conv.is_owned = false;
28044         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
28045         return ret_conv;
28046 }
28047
28048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28049         LDKChannelConfig this_ptr_conv;
28050         this_ptr_conv.inner = untag_ptr(this_ptr);
28051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28053         this_ptr_conv.is_owned = false;
28054         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
28055 }
28056
28057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28058         LDKChannelConfig this_ptr_conv;
28059         this_ptr_conv.inner = untag_ptr(this_ptr);
28060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28062         this_ptr_conv.is_owned = false;
28063         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
28064         return ret_conv;
28065 }
28066
28067 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) {
28068         LDKChannelConfig this_ptr_conv;
28069         this_ptr_conv.inner = untag_ptr(this_ptr);
28070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28072         this_ptr_conv.is_owned = false;
28073         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
28074 }
28075
28076 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) {
28077         LDKChannelConfig this_ptr_conv;
28078         this_ptr_conv.inner = untag_ptr(this_ptr);
28079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28081         this_ptr_conv.is_owned = false;
28082         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
28083         return ret_conv;
28084 }
28085
28086 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) {
28087         LDKChannelConfig this_ptr_conv;
28088         this_ptr_conv.inner = untag_ptr(this_ptr);
28089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28091         this_ptr_conv.is_owned = false;
28092         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
28093 }
28094
28095 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) {
28096         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);
28097         int64_t ret_ref = 0;
28098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28100         return ret_ref;
28101 }
28102
28103 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
28104         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
28105         int64_t ret_ref = 0;
28106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28107         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28108         return ret_ref;
28109 }
28110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28111         LDKChannelConfig arg_conv;
28112         arg_conv.inner = untag_ptr(arg);
28113         arg_conv.is_owned = ptr_is_owned(arg);
28114         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28115         arg_conv.is_owned = false;
28116         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
28117         return ret_conv;
28118 }
28119
28120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28121         LDKChannelConfig orig_conv;
28122         orig_conv.inner = untag_ptr(orig);
28123         orig_conv.is_owned = ptr_is_owned(orig);
28124         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28125         orig_conv.is_owned = false;
28126         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
28127         int64_t ret_ref = 0;
28128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28129         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28130         return ret_ref;
28131 }
28132
28133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28134         LDKChannelConfig a_conv;
28135         a_conv.inner = untag_ptr(a);
28136         a_conv.is_owned = ptr_is_owned(a);
28137         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28138         a_conv.is_owned = false;
28139         LDKChannelConfig b_conv;
28140         b_conv.inner = untag_ptr(b);
28141         b_conv.is_owned = ptr_is_owned(b);
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28143         b_conv.is_owned = false;
28144         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
28145         return ret_conv;
28146 }
28147
28148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
28149         LDKChannelConfig ret_var = ChannelConfig_default();
28150         int64_t ret_ref = 0;
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28152         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28153         return ret_ref;
28154 }
28155
28156 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
28157         LDKChannelConfig obj_conv;
28158         obj_conv.inner = untag_ptr(obj);
28159         obj_conv.is_owned = ptr_is_owned(obj);
28160         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28161         obj_conv.is_owned = false;
28162         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
28163         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28164         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28165         CVec_u8Z_free(ret_var);
28166         return ret_arr;
28167 }
28168
28169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28170         LDKu8slice ser_ref;
28171         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28172         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28173         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
28174         *ret_conv = ChannelConfig_read(ser_ref);
28175         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28176         return tag_ptr(ret_conv, true);
28177 }
28178
28179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28180         LDKUserConfig this_obj_conv;
28181         this_obj_conv.inner = untag_ptr(this_obj);
28182         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28184         UserConfig_free(this_obj_conv);
28185 }
28186
28187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28188         LDKUserConfig this_ptr_conv;
28189         this_ptr_conv.inner = untag_ptr(this_ptr);
28190         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28192         this_ptr_conv.is_owned = false;
28193         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
28194         int64_t ret_ref = 0;
28195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28197         return ret_ref;
28198 }
28199
28200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28201         LDKUserConfig this_ptr_conv;
28202         this_ptr_conv.inner = untag_ptr(this_ptr);
28203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28205         this_ptr_conv.is_owned = false;
28206         LDKChannelHandshakeConfig val_conv;
28207         val_conv.inner = untag_ptr(val);
28208         val_conv.is_owned = ptr_is_owned(val);
28209         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28210         val_conv = ChannelHandshakeConfig_clone(&val_conv);
28211         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
28212 }
28213
28214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
28215         LDKUserConfig this_ptr_conv;
28216         this_ptr_conv.inner = untag_ptr(this_ptr);
28217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28219         this_ptr_conv.is_owned = false;
28220         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
28221         int64_t ret_ref = 0;
28222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28223         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28224         return ret_ref;
28225 }
28226
28227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28228         LDKUserConfig this_ptr_conv;
28229         this_ptr_conv.inner = untag_ptr(this_ptr);
28230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28232         this_ptr_conv.is_owned = false;
28233         LDKChannelHandshakeLimits val_conv;
28234         val_conv.inner = untag_ptr(val);
28235         val_conv.is_owned = ptr_is_owned(val);
28236         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28237         val_conv = ChannelHandshakeLimits_clone(&val_conv);
28238         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
28239 }
28240
28241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28242         LDKUserConfig this_ptr_conv;
28243         this_ptr_conv.inner = untag_ptr(this_ptr);
28244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28246         this_ptr_conv.is_owned = false;
28247         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
28248         int64_t ret_ref = 0;
28249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28251         return ret_ref;
28252 }
28253
28254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28255         LDKUserConfig this_ptr_conv;
28256         this_ptr_conv.inner = untag_ptr(this_ptr);
28257         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28259         this_ptr_conv.is_owned = false;
28260         LDKChannelConfig val_conv;
28261         val_conv.inner = untag_ptr(val);
28262         val_conv.is_owned = ptr_is_owned(val);
28263         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28264         val_conv = ChannelConfig_clone(&val_conv);
28265         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
28266 }
28267
28268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28269         LDKUserConfig this_ptr_conv;
28270         this_ptr_conv.inner = untag_ptr(this_ptr);
28271         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28273         this_ptr_conv.is_owned = false;
28274         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
28275         return ret_conv;
28276 }
28277
28278 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) {
28279         LDKUserConfig this_ptr_conv;
28280         this_ptr_conv.inner = untag_ptr(this_ptr);
28281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28283         this_ptr_conv.is_owned = false;
28284         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
28285 }
28286
28287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28288         LDKUserConfig this_ptr_conv;
28289         this_ptr_conv.inner = untag_ptr(this_ptr);
28290         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28292         this_ptr_conv.is_owned = false;
28293         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
28294         return ret_conv;
28295 }
28296
28297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28298         LDKUserConfig this_ptr_conv;
28299         this_ptr_conv.inner = untag_ptr(this_ptr);
28300         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28302         this_ptr_conv.is_owned = false;
28303         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
28304 }
28305
28306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28307         LDKUserConfig this_ptr_conv;
28308         this_ptr_conv.inner = untag_ptr(this_ptr);
28309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28311         this_ptr_conv.is_owned = false;
28312         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
28313         return ret_conv;
28314 }
28315
28316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28317         LDKUserConfig this_ptr_conv;
28318         this_ptr_conv.inner = untag_ptr(this_ptr);
28319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28321         this_ptr_conv.is_owned = false;
28322         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
28323 }
28324
28325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28326         LDKUserConfig this_ptr_conv;
28327         this_ptr_conv.inner = untag_ptr(this_ptr);
28328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28330         this_ptr_conv.is_owned = false;
28331         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
28332         return ret_conv;
28333 }
28334
28335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28336         LDKUserConfig this_ptr_conv;
28337         this_ptr_conv.inner = untag_ptr(this_ptr);
28338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28340         this_ptr_conv.is_owned = false;
28341         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
28342 }
28343
28344 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) {
28345         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
28346         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
28347         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
28348         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
28349         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
28350         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
28351         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
28352         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
28353         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
28354         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
28355         LDKChannelConfig channel_config_arg_conv;
28356         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
28357         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
28358         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
28359         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
28360         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);
28361         int64_t ret_ref = 0;
28362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28363         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28364         return ret_ref;
28365 }
28366
28367 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
28368         LDKUserConfig ret_var = UserConfig_clone(arg);
28369         int64_t ret_ref = 0;
28370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28372         return ret_ref;
28373 }
28374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28375         LDKUserConfig arg_conv;
28376         arg_conv.inner = untag_ptr(arg);
28377         arg_conv.is_owned = ptr_is_owned(arg);
28378         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28379         arg_conv.is_owned = false;
28380         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
28381         return ret_conv;
28382 }
28383
28384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28385         LDKUserConfig orig_conv;
28386         orig_conv.inner = untag_ptr(orig);
28387         orig_conv.is_owned = ptr_is_owned(orig);
28388         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28389         orig_conv.is_owned = false;
28390         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
28391         int64_t ret_ref = 0;
28392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28394         return ret_ref;
28395 }
28396
28397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
28398         LDKUserConfig ret_var = UserConfig_default();
28399         int64_t ret_ref = 0;
28400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28402         return ret_ref;
28403 }
28404
28405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28406         LDKBestBlock this_obj_conv;
28407         this_obj_conv.inner = untag_ptr(this_obj);
28408         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28410         BestBlock_free(this_obj_conv);
28411 }
28412
28413 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
28414         LDKBestBlock ret_var = BestBlock_clone(arg);
28415         int64_t ret_ref = 0;
28416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28418         return ret_ref;
28419 }
28420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28421         LDKBestBlock arg_conv;
28422         arg_conv.inner = untag_ptr(arg);
28423         arg_conv.is_owned = ptr_is_owned(arg);
28424         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28425         arg_conv.is_owned = false;
28426         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
28427         return ret_conv;
28428 }
28429
28430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28431         LDKBestBlock orig_conv;
28432         orig_conv.inner = untag_ptr(orig);
28433         orig_conv.is_owned = ptr_is_owned(orig);
28434         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28435         orig_conv.is_owned = false;
28436         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
28437         int64_t ret_ref = 0;
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28440         return ret_ref;
28441 }
28442
28443 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28444         LDKBestBlock a_conv;
28445         a_conv.inner = untag_ptr(a);
28446         a_conv.is_owned = ptr_is_owned(a);
28447         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28448         a_conv.is_owned = false;
28449         LDKBestBlock b_conv;
28450         b_conv.inner = untag_ptr(b);
28451         b_conv.is_owned = ptr_is_owned(b);
28452         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28453         b_conv.is_owned = false;
28454         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
28455         return ret_conv;
28456 }
28457
28458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
28459         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
28460         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
28461         int64_t ret_ref = 0;
28462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28464         return ret_ref;
28465 }
28466
28467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
28468         LDKThirtyTwoBytes block_hash_ref;
28469         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
28470         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
28471         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
28472         int64_t ret_ref = 0;
28473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28474         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28475         return ret_ref;
28476 }
28477
28478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
28479         LDKBestBlock this_arg_conv;
28480         this_arg_conv.inner = untag_ptr(this_arg);
28481         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28483         this_arg_conv.is_owned = false;
28484         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28485         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
28486         return ret_arr;
28487 }
28488
28489 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
28490         LDKBestBlock this_arg_conv;
28491         this_arg_conv.inner = untag_ptr(this_arg);
28492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28494         this_arg_conv.is_owned = false;
28495         int32_t ret_conv = BestBlock_height(&this_arg_conv);
28496         return ret_conv;
28497 }
28498
28499 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28500         LDKAccessError* orig_conv = (LDKAccessError*)untag_ptr(orig);
28501         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
28502         return ret_conv;
28503 }
28504
28505 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
28506         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
28507         return ret_conv;
28508 }
28509
28510 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
28511         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
28512         return ret_conv;
28513 }
28514
28515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28516         if (!ptr_is_owned(this_ptr)) return;
28517         void* this_ptr_ptr = untag_ptr(this_ptr);
28518         CHECK_ACCESS(this_ptr_ptr);
28519         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
28520         FREE(untag_ptr(this_ptr));
28521         Access_free(this_ptr_conv);
28522 }
28523
28524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28525         if (!ptr_is_owned(this_ptr)) return;
28526         void* this_ptr_ptr = untag_ptr(this_ptr);
28527         CHECK_ACCESS(this_ptr_ptr);
28528         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
28529         FREE(untag_ptr(this_ptr));
28530         Listen_free(this_ptr_conv);
28531 }
28532
28533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28534         if (!ptr_is_owned(this_ptr)) return;
28535         void* this_ptr_ptr = untag_ptr(this_ptr);
28536         CHECK_ACCESS(this_ptr_ptr);
28537         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
28538         FREE(untag_ptr(this_ptr));
28539         Confirm_free(this_ptr_conv);
28540 }
28541
28542 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28543         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
28544         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
28545         return ret_conv;
28546 }
28547
28548 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
28549         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
28550         return ret_conv;
28551 }
28552
28553 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
28554         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
28555         return ret_conv;
28556 }
28557
28558 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
28559         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
28560         return ret_conv;
28561 }
28562
28563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28564         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
28565         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
28566         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
28567         return ret_conv;
28568 }
28569
28570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28571         if (!ptr_is_owned(this_ptr)) return;
28572         void* this_ptr_ptr = untag_ptr(this_ptr);
28573         CHECK_ACCESS(this_ptr_ptr);
28574         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
28575         FREE(untag_ptr(this_ptr));
28576         Watch_free(this_ptr_conv);
28577 }
28578
28579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28580         if (!ptr_is_owned(this_ptr)) return;
28581         void* this_ptr_ptr = untag_ptr(this_ptr);
28582         CHECK_ACCESS(this_ptr_ptr);
28583         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
28584         FREE(untag_ptr(this_ptr));
28585         Filter_free(this_ptr_conv);
28586 }
28587
28588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28589         LDKWatchedOutput this_obj_conv;
28590         this_obj_conv.inner = untag_ptr(this_obj);
28591         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28593         WatchedOutput_free(this_obj_conv);
28594 }
28595
28596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28597         LDKWatchedOutput this_ptr_conv;
28598         this_ptr_conv.inner = untag_ptr(this_ptr);
28599         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28601         this_ptr_conv.is_owned = false;
28602         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
28604         return ret_arr;
28605 }
28606
28607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28608         LDKWatchedOutput this_ptr_conv;
28609         this_ptr_conv.inner = untag_ptr(this_ptr);
28610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28612         this_ptr_conv.is_owned = false;
28613         LDKThirtyTwoBytes val_ref;
28614         CHECK((*env)->GetArrayLength(env, val) == 32);
28615         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28616         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
28617 }
28618
28619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28620         LDKWatchedOutput this_ptr_conv;
28621         this_ptr_conv.inner = untag_ptr(this_ptr);
28622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28624         this_ptr_conv.is_owned = false;
28625         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
28626         int64_t ret_ref = 0;
28627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28629         return ret_ref;
28630 }
28631
28632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28633         LDKWatchedOutput this_ptr_conv;
28634         this_ptr_conv.inner = untag_ptr(this_ptr);
28635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28637         this_ptr_conv.is_owned = false;
28638         LDKOutPoint val_conv;
28639         val_conv.inner = untag_ptr(val);
28640         val_conv.is_owned = ptr_is_owned(val);
28641         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28642         val_conv = OutPoint_clone(&val_conv);
28643         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
28644 }
28645
28646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28647         LDKWatchedOutput this_ptr_conv;
28648         this_ptr_conv.inner = untag_ptr(this_ptr);
28649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28651         this_ptr_conv.is_owned = false;
28652         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
28653         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28654         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28655         return ret_arr;
28656 }
28657
28658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28659         LDKWatchedOutput this_ptr_conv;
28660         this_ptr_conv.inner = untag_ptr(this_ptr);
28661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28663         this_ptr_conv.is_owned = false;
28664         LDKCVec_u8Z val_ref;
28665         val_ref.datalen = (*env)->GetArrayLength(env, val);
28666         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
28667         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
28668         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
28669 }
28670
28671 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) {
28672         LDKThirtyTwoBytes block_hash_arg_ref;
28673         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
28674         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
28675         LDKOutPoint outpoint_arg_conv;
28676         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
28677         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
28678         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28679         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28680         LDKCVec_u8Z script_pubkey_arg_ref;
28681         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
28682         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
28683         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
28684         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
28685         int64_t ret_ref = 0;
28686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28688         return ret_ref;
28689 }
28690
28691 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
28692         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
28693         int64_t ret_ref = 0;
28694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28696         return ret_ref;
28697 }
28698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28699         LDKWatchedOutput arg_conv;
28700         arg_conv.inner = untag_ptr(arg);
28701         arg_conv.is_owned = ptr_is_owned(arg);
28702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28703         arg_conv.is_owned = false;
28704         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
28705         return ret_conv;
28706 }
28707
28708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28709         LDKWatchedOutput orig_conv;
28710         orig_conv.inner = untag_ptr(orig);
28711         orig_conv.is_owned = ptr_is_owned(orig);
28712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28713         orig_conv.is_owned = false;
28714         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
28715         int64_t ret_ref = 0;
28716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28718         return ret_ref;
28719 }
28720
28721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28722         LDKWatchedOutput a_conv;
28723         a_conv.inner = untag_ptr(a);
28724         a_conv.is_owned = ptr_is_owned(a);
28725         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28726         a_conv.is_owned = false;
28727         LDKWatchedOutput b_conv;
28728         b_conv.inner = untag_ptr(b);
28729         b_conv.is_owned = ptr_is_owned(b);
28730         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28731         b_conv.is_owned = false;
28732         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
28733         return ret_conv;
28734 }
28735
28736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
28737         LDKWatchedOutput o_conv;
28738         o_conv.inner = untag_ptr(o);
28739         o_conv.is_owned = ptr_is_owned(o);
28740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28741         o_conv.is_owned = false;
28742         int64_t ret_conv = WatchedOutput_hash(&o_conv);
28743         return ret_conv;
28744 }
28745
28746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28747         if (!ptr_is_owned(this_ptr)) return;
28748         void* this_ptr_ptr = untag_ptr(this_ptr);
28749         CHECK_ACCESS(this_ptr_ptr);
28750         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
28751         FREE(untag_ptr(this_ptr));
28752         BroadcasterInterface_free(this_ptr_conv);
28753 }
28754
28755 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28756         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
28757         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
28758         return ret_conv;
28759 }
28760
28761 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
28762         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
28763         return ret_conv;
28764 }
28765
28766 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
28767         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
28768         return ret_conv;
28769 }
28770
28771 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
28772         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
28773         return ret_conv;
28774 }
28775
28776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1hash(JNIEnv *env, jclass clz, int64_t o) {
28777         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
28778         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
28779         return ret_conv;
28780 }
28781
28782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28783         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
28784         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
28785         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
28786         return ret_conv;
28787 }
28788
28789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28790         if (!ptr_is_owned(this_ptr)) return;
28791         void* this_ptr_ptr = untag_ptr(this_ptr);
28792         CHECK_ACCESS(this_ptr_ptr);
28793         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
28794         FREE(untag_ptr(this_ptr));
28795         FeeEstimator_free(this_ptr_conv);
28796 }
28797
28798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28799         LDKMonitorUpdateId this_obj_conv;
28800         this_obj_conv.inner = untag_ptr(this_obj);
28801         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28803         MonitorUpdateId_free(this_obj_conv);
28804 }
28805
28806 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
28807         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
28808         int64_t ret_ref = 0;
28809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28811         return ret_ref;
28812 }
28813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28814         LDKMonitorUpdateId arg_conv;
28815         arg_conv.inner = untag_ptr(arg);
28816         arg_conv.is_owned = ptr_is_owned(arg);
28817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28818         arg_conv.is_owned = false;
28819         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
28820         return ret_conv;
28821 }
28822
28823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28824         LDKMonitorUpdateId orig_conv;
28825         orig_conv.inner = untag_ptr(orig);
28826         orig_conv.is_owned = ptr_is_owned(orig);
28827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28828         orig_conv.is_owned = false;
28829         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
28830         int64_t ret_ref = 0;
28831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28833         return ret_ref;
28834 }
28835
28836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
28837         LDKMonitorUpdateId o_conv;
28838         o_conv.inner = untag_ptr(o);
28839         o_conv.is_owned = ptr_is_owned(o);
28840         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28841         o_conv.is_owned = false;
28842         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
28843         return ret_conv;
28844 }
28845
28846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28847         LDKMonitorUpdateId a_conv;
28848         a_conv.inner = untag_ptr(a);
28849         a_conv.is_owned = ptr_is_owned(a);
28850         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28851         a_conv.is_owned = false;
28852         LDKMonitorUpdateId b_conv;
28853         b_conv.inner = untag_ptr(b);
28854         b_conv.is_owned = ptr_is_owned(b);
28855         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28856         b_conv.is_owned = false;
28857         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
28858         return ret_conv;
28859 }
28860
28861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28862         if (!ptr_is_owned(this_ptr)) return;
28863         void* this_ptr_ptr = untag_ptr(this_ptr);
28864         CHECK_ACCESS(this_ptr_ptr);
28865         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
28866         FREE(untag_ptr(this_ptr));
28867         Persist_free(this_ptr_conv);
28868 }
28869
28870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28871         LDKLockedChannelMonitor this_obj_conv;
28872         this_obj_conv.inner = untag_ptr(this_obj);
28873         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28875         LockedChannelMonitor_free(this_obj_conv);
28876 }
28877
28878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28879         LDKChainMonitor this_obj_conv;
28880         this_obj_conv.inner = untag_ptr(this_obj);
28881         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28883         ChainMonitor_free(this_obj_conv);
28884 }
28885
28886 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) {
28887         void* chain_source_ptr = untag_ptr(chain_source);
28888         CHECK_ACCESS(chain_source_ptr);
28889         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
28890         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
28891         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
28892                 // Manually implement clone for Java trait instances
28893                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
28894                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28895                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
28896                 }
28897         }
28898         void* broadcaster_ptr = untag_ptr(broadcaster);
28899         CHECK_ACCESS(broadcaster_ptr);
28900         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28901         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28902                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28903                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28904         }
28905         void* logger_ptr = untag_ptr(logger);
28906         CHECK_ACCESS(logger_ptr);
28907         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28908         if (logger_conv.free == LDKLogger_JCalls_free) {
28909                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28910                 LDKLogger_JCalls_cloned(&logger_conv);
28911         }
28912         void* feeest_ptr = untag_ptr(feeest);
28913         CHECK_ACCESS(feeest_ptr);
28914         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
28915         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
28916                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28917                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
28918         }
28919         void* persister_ptr = untag_ptr(persister);
28920         CHECK_ACCESS(persister_ptr);
28921         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
28922         if (persister_conv.free == LDKPersist_JCalls_free) {
28923                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28924                 LDKPersist_JCalls_cloned(&persister_conv);
28925         }
28926         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
28927         int64_t ret_ref = 0;
28928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28930         return ret_ref;
28931 }
28932
28933 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) {
28934         LDKChainMonitor this_arg_conv;
28935         this_arg_conv.inner = untag_ptr(this_arg);
28936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28938         this_arg_conv.is_owned = false;
28939         LDKCVec_ChannelDetailsZ ignored_channels_constr;
28940         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
28941         if (ignored_channels_constr.datalen > 0)
28942                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28943         else
28944                 ignored_channels_constr.data = NULL;
28945         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
28946         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
28947                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
28948                 LDKChannelDetails ignored_channels_conv_16_conv;
28949                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
28950                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
28951                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
28952                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
28953                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
28954         }
28955         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
28956         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
28957         int64_tArray ret_arr = NULL;
28958         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28959         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28960         for (size_t j = 0; j < ret_var.datalen; j++) {
28961                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28962                 *ret_conv_9_copy = ret_var.data[j];
28963                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
28964                 ret_arr_ptr[j] = ret_conv_9_ref;
28965         }
28966         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28967         FREE(ret_var.data);
28968         return ret_arr;
28969 }
28970
28971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
28972         LDKChainMonitor this_arg_conv;
28973         this_arg_conv.inner = untag_ptr(this_arg);
28974         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28976         this_arg_conv.is_owned = false;
28977         LDKOutPoint funding_txo_conv;
28978         funding_txo_conv.inner = untag_ptr(funding_txo);
28979         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28980         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28981         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28982         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
28983         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
28984         return tag_ptr(ret_conv, true);
28985 }
28986
28987 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
28988         LDKChainMonitor this_arg_conv;
28989         this_arg_conv.inner = untag_ptr(this_arg);
28990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28992         this_arg_conv.is_owned = false;
28993         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
28994         int64_tArray ret_arr = NULL;
28995         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28996         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28997         for (size_t k = 0; k < ret_var.datalen; k++) {
28998                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
28999                 int64_t ret_conv_10_ref = 0;
29000                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
29001                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
29002                 ret_arr_ptr[k] = ret_conv_10_ref;
29003         }
29004         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29005         FREE(ret_var.data);
29006         return ret_arr;
29007 }
29008
29009 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1pending_1monitor_1updates(JNIEnv *env, jclass clz, int64_t this_arg) {
29010         LDKChainMonitor this_arg_conv;
29011         this_arg_conv.inner = untag_ptr(this_arg);
29012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29014         this_arg_conv.is_owned = false;
29015         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
29016         int64_tArray ret_arr = NULL;
29017         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29018         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29019         for (size_t p = 0; p < ret_var.datalen; p++) {
29020                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29021                 *ret_conv_41_conv = ret_var.data[p];
29022                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
29023         }
29024         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29025         FREE(ret_var.data);
29026         return ret_arr;
29027 }
29028
29029 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) {
29030         LDKChainMonitor this_arg_conv;
29031         this_arg_conv.inner = untag_ptr(this_arg);
29032         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29034         this_arg_conv.is_owned = false;
29035         LDKOutPoint funding_txo_conv;
29036         funding_txo_conv.inner = untag_ptr(funding_txo);
29037         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29039         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29040         LDKMonitorUpdateId completed_update_id_conv;
29041         completed_update_id_conv.inner = untag_ptr(completed_update_id);
29042         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
29043         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
29044         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
29045         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29046         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
29047         return tag_ptr(ret_conv, true);
29048 }
29049
29050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29051         LDKChainMonitor this_arg_conv;
29052         this_arg_conv.inner = untag_ptr(this_arg);
29053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29055         this_arg_conv.is_owned = false;
29056         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29057         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
29058         return tag_ptr(ret_ret, true);
29059 }
29060
29061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29062         LDKChainMonitor this_arg_conv;
29063         this_arg_conv.inner = untag_ptr(this_arg);
29064         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29066         this_arg_conv.is_owned = false;
29067         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29068         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
29069         return tag_ptr(ret_ret, true);
29070 }
29071
29072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29073         LDKChainMonitor this_arg_conv;
29074         this_arg_conv.inner = untag_ptr(this_arg);
29075         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29077         this_arg_conv.is_owned = false;
29078         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
29079         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
29080         return tag_ptr(ret_ret, true);
29081 }
29082
29083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29084         LDKChainMonitor this_arg_conv;
29085         this_arg_conv.inner = untag_ptr(this_arg);
29086         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29088         this_arg_conv.is_owned = false;
29089         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29090         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
29091         return tag_ptr(ret_ret, true);
29092 }
29093
29094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29095         LDKChannelMonitorUpdate this_obj_conv;
29096         this_obj_conv.inner = untag_ptr(this_obj);
29097         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29099         ChannelMonitorUpdate_free(this_obj_conv);
29100 }
29101
29102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29103         LDKChannelMonitorUpdate this_ptr_conv;
29104         this_ptr_conv.inner = untag_ptr(this_ptr);
29105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29107         this_ptr_conv.is_owned = false;
29108         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
29109         return ret_conv;
29110 }
29111
29112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29113         LDKChannelMonitorUpdate this_ptr_conv;
29114         this_ptr_conv.inner = untag_ptr(this_ptr);
29115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29117         this_ptr_conv.is_owned = false;
29118         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
29119 }
29120
29121 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
29122         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
29123         int64_t ret_ref = 0;
29124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29125         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29126         return ret_ref;
29127 }
29128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29129         LDKChannelMonitorUpdate arg_conv;
29130         arg_conv.inner = untag_ptr(arg);
29131         arg_conv.is_owned = ptr_is_owned(arg);
29132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29133         arg_conv.is_owned = false;
29134         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
29135         return ret_conv;
29136 }
29137
29138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29139         LDKChannelMonitorUpdate orig_conv;
29140         orig_conv.inner = untag_ptr(orig);
29141         orig_conv.is_owned = ptr_is_owned(orig);
29142         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29143         orig_conv.is_owned = false;
29144         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
29145         int64_t ret_ref = 0;
29146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29148         return ret_ref;
29149 }
29150
29151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29152         LDKChannelMonitorUpdate obj_conv;
29153         obj_conv.inner = untag_ptr(obj);
29154         obj_conv.is_owned = ptr_is_owned(obj);
29155         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29156         obj_conv.is_owned = false;
29157         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
29158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29160         CVec_u8Z_free(ret_var);
29161         return ret_arr;
29162 }
29163
29164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29165         LDKu8slice ser_ref;
29166         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29167         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29168         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
29169         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
29170         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29171         return tag_ptr(ret_conv, true);
29172 }
29173
29174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29175         if (!ptr_is_owned(this_ptr)) return;
29176         void* this_ptr_ptr = untag_ptr(this_ptr);
29177         CHECK_ACCESS(this_ptr_ptr);
29178         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
29179         FREE(untag_ptr(this_ptr));
29180         MonitorEvent_free(this_ptr_conv);
29181 }
29182
29183 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
29184         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29185         *ret_copy = MonitorEvent_clone(arg);
29186         int64_t ret_ref = tag_ptr(ret_copy, true);
29187         return ret_ref;
29188 }
29189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29190         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
29191         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
29192         return ret_conv;
29193 }
29194
29195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29196         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
29197         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29198         *ret_copy = MonitorEvent_clone(orig_conv);
29199         int64_t ret_ref = tag_ptr(ret_copy, true);
29200         return ret_ref;
29201 }
29202
29203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
29204         LDKHTLCUpdate a_conv;
29205         a_conv.inner = untag_ptr(a);
29206         a_conv.is_owned = ptr_is_owned(a);
29207         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29208         a_conv = HTLCUpdate_clone(&a_conv);
29209         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29210         *ret_copy = MonitorEvent_htlcevent(a_conv);
29211         int64_t ret_ref = tag_ptr(ret_copy, true);
29212         return ret_ref;
29213 }
29214
29215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
29216         LDKOutPoint a_conv;
29217         a_conv.inner = untag_ptr(a);
29218         a_conv.is_owned = ptr_is_owned(a);
29219         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29220         a_conv = OutPoint_clone(&a_conv);
29221         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29222         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
29223         int64_t ret_ref = tag_ptr(ret_copy, true);
29224         return ret_ref;
29225 }
29226
29227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
29228         LDKOutPoint funding_txo_conv;
29229         funding_txo_conv.inner = untag_ptr(funding_txo);
29230         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29231         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29232         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29233         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29234         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
29235         int64_t ret_ref = tag_ptr(ret_copy, true);
29236         return ret_ref;
29237 }
29238
29239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
29240         LDKOutPoint a_conv;
29241         a_conv.inner = untag_ptr(a);
29242         a_conv.is_owned = ptr_is_owned(a);
29243         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29244         a_conv = OutPoint_clone(&a_conv);
29245         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29246         *ret_copy = MonitorEvent_update_failed(a_conv);
29247         int64_t ret_ref = tag_ptr(ret_copy, true);
29248         return ret_ref;
29249 }
29250
29251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29252         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
29253         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
29254         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
29255         return ret_conv;
29256 }
29257
29258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
29259         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
29260         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
29261         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29262         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29263         CVec_u8Z_free(ret_var);
29264         return ret_arr;
29265 }
29266
29267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29268         LDKu8slice ser_ref;
29269         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29270         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29271         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
29272         *ret_conv = MonitorEvent_read(ser_ref);
29273         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29274         return tag_ptr(ret_conv, true);
29275 }
29276
29277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29278         LDKHTLCUpdate this_obj_conv;
29279         this_obj_conv.inner = untag_ptr(this_obj);
29280         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29282         HTLCUpdate_free(this_obj_conv);
29283 }
29284
29285 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
29286         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
29287         int64_t ret_ref = 0;
29288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29290         return ret_ref;
29291 }
29292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29293         LDKHTLCUpdate arg_conv;
29294         arg_conv.inner = untag_ptr(arg);
29295         arg_conv.is_owned = ptr_is_owned(arg);
29296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29297         arg_conv.is_owned = false;
29298         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
29299         return ret_conv;
29300 }
29301
29302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29303         LDKHTLCUpdate orig_conv;
29304         orig_conv.inner = untag_ptr(orig);
29305         orig_conv.is_owned = ptr_is_owned(orig);
29306         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29307         orig_conv.is_owned = false;
29308         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
29309         int64_t ret_ref = 0;
29310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29311         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29312         return ret_ref;
29313 }
29314
29315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29316         LDKHTLCUpdate a_conv;
29317         a_conv.inner = untag_ptr(a);
29318         a_conv.is_owned = ptr_is_owned(a);
29319         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29320         a_conv.is_owned = false;
29321         LDKHTLCUpdate b_conv;
29322         b_conv.inner = untag_ptr(b);
29323         b_conv.is_owned = ptr_is_owned(b);
29324         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29325         b_conv.is_owned = false;
29326         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
29327         return ret_conv;
29328 }
29329
29330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29331         LDKHTLCUpdate obj_conv;
29332         obj_conv.inner = untag_ptr(obj);
29333         obj_conv.is_owned = ptr_is_owned(obj);
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29335         obj_conv.is_owned = false;
29336         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
29337         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29338         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29339         CVec_u8Z_free(ret_var);
29340         return ret_arr;
29341 }
29342
29343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29344         LDKu8slice ser_ref;
29345         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29346         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29347         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
29348         *ret_conv = HTLCUpdate_read(ser_ref);
29349         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29350         return tag_ptr(ret_conv, true);
29351 }
29352
29353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29354         if (!ptr_is_owned(this_ptr)) return;
29355         void* this_ptr_ptr = untag_ptr(this_ptr);
29356         CHECK_ACCESS(this_ptr_ptr);
29357         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
29358         FREE(untag_ptr(this_ptr));
29359         Balance_free(this_ptr_conv);
29360 }
29361
29362 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
29363         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29364         *ret_copy = Balance_clone(arg);
29365         int64_t ret_ref = tag_ptr(ret_copy, true);
29366         return ret_ref;
29367 }
29368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29369         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
29370         int64_t ret_conv = Balance_clone_ptr(arg_conv);
29371         return ret_conv;
29372 }
29373
29374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29375         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
29376         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29377         *ret_copy = Balance_clone(orig_conv);
29378         int64_t ret_ref = tag_ptr(ret_copy, true);
29379         return ret_ref;
29380 }
29381
29382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29383         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29384         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
29385         int64_t ret_ref = tag_ptr(ret_copy, true);
29386         return ret_ref;
29387 }
29388
29389 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) {
29390         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29391         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
29392         int64_t ret_ref = tag_ptr(ret_copy, true);
29393         return ret_ref;
29394 }
29395
29396 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) {
29397         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29398         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
29399         int64_t ret_ref = tag_ptr(ret_copy, true);
29400         return ret_ref;
29401 }
29402
29403 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) {
29404         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29405         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
29406         int64_t ret_ref = tag_ptr(ret_copy, true);
29407         return ret_ref;
29408 }
29409
29410 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) {
29411         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29412         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
29413         int64_t ret_ref = tag_ptr(ret_copy, true);
29414         return ret_ref;
29415 }
29416
29417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29418         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29419         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
29420         int64_t ret_ref = tag_ptr(ret_copy, true);
29421         return ret_ref;
29422 }
29423
29424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29425         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
29426         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
29427         jboolean ret_conv = Balance_eq(a_conv, b_conv);
29428         return ret_conv;
29429 }
29430
29431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29432         LDKChannelMonitor this_obj_conv;
29433         this_obj_conv.inner = untag_ptr(this_obj);
29434         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29436         ChannelMonitor_free(this_obj_conv);
29437 }
29438
29439 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
29440         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
29441         int64_t ret_ref = 0;
29442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29444         return ret_ref;
29445 }
29446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29447         LDKChannelMonitor arg_conv;
29448         arg_conv.inner = untag_ptr(arg);
29449         arg_conv.is_owned = ptr_is_owned(arg);
29450         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29451         arg_conv.is_owned = false;
29452         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
29453         return ret_conv;
29454 }
29455
29456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29457         LDKChannelMonitor orig_conv;
29458         orig_conv.inner = untag_ptr(orig);
29459         orig_conv.is_owned = ptr_is_owned(orig);
29460         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29461         orig_conv.is_owned = false;
29462         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
29463         int64_t ret_ref = 0;
29464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29465         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29466         return ret_ref;
29467 }
29468
29469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29470         LDKChannelMonitor obj_conv;
29471         obj_conv.inner = untag_ptr(obj);
29472         obj_conv.is_owned = ptr_is_owned(obj);
29473         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29474         obj_conv.is_owned = false;
29475         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
29476         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29477         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29478         CVec_u8Z_free(ret_var);
29479         return ret_arr;
29480 }
29481
29482 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) {
29483         LDKChannelMonitor this_arg_conv;
29484         this_arg_conv.inner = untag_ptr(this_arg);
29485         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29487         this_arg_conv.is_owned = false;
29488         LDKChannelMonitorUpdate updates_conv;
29489         updates_conv.inner = untag_ptr(updates);
29490         updates_conv.is_owned = ptr_is_owned(updates);
29491         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
29492         updates_conv.is_owned = false;
29493         void* broadcaster_ptr = untag_ptr(broadcaster);
29494         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
29495         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
29496         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29497         CHECK_ACCESS(fee_estimator_ptr);
29498         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29499         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29500                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29501                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29502         }
29503         void* logger_ptr = untag_ptr(logger);
29504         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29505         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29506         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
29507         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
29508         return tag_ptr(ret_conv, true);
29509 }
29510
29511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29512         LDKChannelMonitor this_arg_conv;
29513         this_arg_conv.inner = untag_ptr(this_arg);
29514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29516         this_arg_conv.is_owned = false;
29517         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
29518         return ret_conv;
29519 }
29520
29521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
29522         LDKChannelMonitor this_arg_conv;
29523         this_arg_conv.inner = untag_ptr(this_arg);
29524         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29526         this_arg_conv.is_owned = false;
29527         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
29528         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
29529         return tag_ptr(ret_conv, true);
29530 }
29531
29532 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29533         LDKChannelMonitor this_arg_conv;
29534         this_arg_conv.inner = untag_ptr(this_arg);
29535         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29537         this_arg_conv.is_owned = false;
29538         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
29539         int64_tArray ret_arr = NULL;
29540         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29541         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29542         for (size_t o = 0; o < ret_var.datalen; o++) {
29543                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
29544                 *ret_conv_40_conv = ret_var.data[o];
29545                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
29546         }
29547         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29548         FREE(ret_var.data);
29549         return ret_arr;
29550 }
29551
29552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
29553         LDKChannelMonitor this_arg_conv;
29554         this_arg_conv.inner = untag_ptr(this_arg);
29555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29557         this_arg_conv.is_owned = false;
29558         void* filter_ptr = untag_ptr(filter);
29559         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
29560         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
29561         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
29562 }
29563
29564 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29565         LDKChannelMonitor this_arg_conv;
29566         this_arg_conv.inner = untag_ptr(this_arg);
29567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29569         this_arg_conv.is_owned = false;
29570         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
29571         int64_tArray ret_arr = NULL;
29572         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29573         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29574         for (size_t o = 0; o < ret_var.datalen; o++) {
29575                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29576                 *ret_conv_14_copy = ret_var.data[o];
29577                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
29578                 ret_arr_ptr[o] = ret_conv_14_ref;
29579         }
29580         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29581         FREE(ret_var.data);
29582         return ret_arr;
29583 }
29584
29585 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29586         LDKChannelMonitor this_arg_conv;
29587         this_arg_conv.inner = untag_ptr(this_arg);
29588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29590         this_arg_conv.is_owned = false;
29591         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
29592         int64_tArray ret_arr = NULL;
29593         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29594         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29595         for (size_t h = 0; h < ret_var.datalen; h++) {
29596                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
29597                 *ret_conv_7_copy = ret_var.data[h];
29598                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
29599                 ret_arr_ptr[h] = ret_conv_7_ref;
29600         }
29601         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29602         FREE(ret_var.data);
29603         return ret_arr;
29604 }
29605
29606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29607         LDKChannelMonitor this_arg_conv;
29608         this_arg_conv.inner = untag_ptr(this_arg);
29609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29611         this_arg_conv.is_owned = false;
29612         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
29614         return ret_arr;
29615 }
29616
29617 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) {
29618         LDKChannelMonitor this_arg_conv;
29619         this_arg_conv.inner = untag_ptr(this_arg);
29620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29622         this_arg_conv.is_owned = false;
29623         void* logger_ptr = untag_ptr(logger);
29624         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29625         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29626         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
29627         jobjectArray ret_arr = NULL;
29628         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
29629         ;
29630         for (size_t i = 0; i < ret_var.datalen; i++) {
29631                 LDKTransaction ret_conv_8_var = ret_var.data[i];
29632                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
29633                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
29634                 Transaction_free(ret_conv_8_var);
29635                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
29636         }
29637         
29638         FREE(ret_var.data);
29639         return ret_arr;
29640 }
29641
29642 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) {
29643         LDKChannelMonitor this_arg_conv;
29644         this_arg_conv.inner = untag_ptr(this_arg);
29645         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29647         this_arg_conv.is_owned = false;
29648         unsigned char header_arr[80];
29649         CHECK((*env)->GetArrayLength(env, header) == 80);
29650         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29651         unsigned char (*header_ref)[80] = &header_arr;
29652         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29653         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
29654         if (txdata_constr.datalen > 0)
29655                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
29656         else
29657                 txdata_constr.data = NULL;
29658         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
29659         for (size_t c = 0; c < txdata_constr.datalen; c++) {
29660                 int64_t txdata_conv_28 = txdata_vals[c];
29661                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
29662                 CHECK_ACCESS(txdata_conv_28_ptr);
29663                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
29664                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
29665                 txdata_constr.data[c] = txdata_conv_28_conv;
29666         }
29667         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
29668         void* broadcaster_ptr = untag_ptr(broadcaster);
29669         CHECK_ACCESS(broadcaster_ptr);
29670         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29671         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29672                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29673                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29674         }
29675         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29676         CHECK_ACCESS(fee_estimator_ptr);
29677         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29678         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29679                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29680                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29681         }
29682         void* logger_ptr = untag_ptr(logger);
29683         CHECK_ACCESS(logger_ptr);
29684         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29685         if (logger_conv.free == LDKLogger_JCalls_free) {
29686                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29687                 LDKLogger_JCalls_cloned(&logger_conv);
29688         }
29689         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);
29690         int64_tArray ret_arr = NULL;
29691         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29692         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29693         for (size_t n = 0; n < ret_var.datalen; n++) {
29694                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
29695                 *ret_conv_39_conv = ret_var.data[n];
29696                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
29697         }
29698         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29699         FREE(ret_var.data);
29700         return ret_arr;
29701 }
29702
29703 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) {
29704         LDKChannelMonitor this_arg_conv;
29705         this_arg_conv.inner = untag_ptr(this_arg);
29706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29708         this_arg_conv.is_owned = false;
29709         unsigned char header_arr[80];
29710         CHECK((*env)->GetArrayLength(env, header) == 80);
29711         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29712         unsigned char (*header_ref)[80] = &header_arr;
29713         void* broadcaster_ptr = untag_ptr(broadcaster);
29714         CHECK_ACCESS(broadcaster_ptr);
29715         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29716         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29717                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29718                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29719         }
29720         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29721         CHECK_ACCESS(fee_estimator_ptr);
29722         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29723         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29724                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29725                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29726         }
29727         void* logger_ptr = untag_ptr(logger);
29728         CHECK_ACCESS(logger_ptr);
29729         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29730         if (logger_conv.free == LDKLogger_JCalls_free) {
29731                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29732                 LDKLogger_JCalls_cloned(&logger_conv);
29733         }
29734         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
29735 }
29736
29737 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) {
29738         LDKChannelMonitor this_arg_conv;
29739         this_arg_conv.inner = untag_ptr(this_arg);
29740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29742         this_arg_conv.is_owned = false;
29743         unsigned char header_arr[80];
29744         CHECK((*env)->GetArrayLength(env, header) == 80);
29745         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29746         unsigned char (*header_ref)[80] = &header_arr;
29747         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29748         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
29749         if (txdata_constr.datalen > 0)
29750                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
29751         else
29752                 txdata_constr.data = NULL;
29753         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
29754         for (size_t c = 0; c < txdata_constr.datalen; c++) {
29755                 int64_t txdata_conv_28 = txdata_vals[c];
29756                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
29757                 CHECK_ACCESS(txdata_conv_28_ptr);
29758                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
29759                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
29760                 txdata_constr.data[c] = txdata_conv_28_conv;
29761         }
29762         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
29763         void* broadcaster_ptr = untag_ptr(broadcaster);
29764         CHECK_ACCESS(broadcaster_ptr);
29765         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29766         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29768                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29769         }
29770         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29771         CHECK_ACCESS(fee_estimator_ptr);
29772         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29773         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29774                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29775                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29776         }
29777         void* logger_ptr = untag_ptr(logger);
29778         CHECK_ACCESS(logger_ptr);
29779         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29780         if (logger_conv.free == LDKLogger_JCalls_free) {
29781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29782                 LDKLogger_JCalls_cloned(&logger_conv);
29783         }
29784         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);
29785         int64_tArray ret_arr = NULL;
29786         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29787         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29788         for (size_t n = 0; n < ret_var.datalen; n++) {
29789                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
29790                 *ret_conv_39_conv = ret_var.data[n];
29791                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
29792         }
29793         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29794         FREE(ret_var.data);
29795         return ret_arr;
29796 }
29797
29798 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) {
29799         LDKChannelMonitor this_arg_conv;
29800         this_arg_conv.inner = untag_ptr(this_arg);
29801         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29803         this_arg_conv.is_owned = false;
29804         unsigned char txid_arr[32];
29805         CHECK((*env)->GetArrayLength(env, txid) == 32);
29806         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
29807         unsigned char (*txid_ref)[32] = &txid_arr;
29808         void* broadcaster_ptr = untag_ptr(broadcaster);
29809         CHECK_ACCESS(broadcaster_ptr);
29810         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29811         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29812                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29813                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29814         }
29815         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29816         CHECK_ACCESS(fee_estimator_ptr);
29817         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29818         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29819                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29820                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29821         }
29822         void* logger_ptr = untag_ptr(logger);
29823         CHECK_ACCESS(logger_ptr);
29824         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29825         if (logger_conv.free == LDKLogger_JCalls_free) {
29826                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29827                 LDKLogger_JCalls_cloned(&logger_conv);
29828         }
29829         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
29830 }
29831
29832 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) {
29833         LDKChannelMonitor this_arg_conv;
29834         this_arg_conv.inner = untag_ptr(this_arg);
29835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29837         this_arg_conv.is_owned = false;
29838         unsigned char header_arr[80];
29839         CHECK((*env)->GetArrayLength(env, header) == 80);
29840         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29841         unsigned char (*header_ref)[80] = &header_arr;
29842         void* broadcaster_ptr = untag_ptr(broadcaster);
29843         CHECK_ACCESS(broadcaster_ptr);
29844         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29845         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29847                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29848         }
29849         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29850         CHECK_ACCESS(fee_estimator_ptr);
29851         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29852         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29853                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29854                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29855         }
29856         void* logger_ptr = untag_ptr(logger);
29857         CHECK_ACCESS(logger_ptr);
29858         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29859         if (logger_conv.free == LDKLogger_JCalls_free) {
29860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29861                 LDKLogger_JCalls_cloned(&logger_conv);
29862         }
29863         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
29864         int64_tArray ret_arr = NULL;
29865         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29866         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29867         for (size_t n = 0; n < ret_var.datalen; n++) {
29868                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
29869                 *ret_conv_39_conv = ret_var.data[n];
29870                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
29871         }
29872         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29873         FREE(ret_var.data);
29874         return ret_arr;
29875 }
29876
29877 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
29878         LDKChannelMonitor this_arg_conv;
29879         this_arg_conv.inner = untag_ptr(this_arg);
29880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29882         this_arg_conv.is_owned = false;
29883         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
29884         int64_tArray ret_arr = NULL;
29885         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29886         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29887         for (size_t z = 0; z < ret_var.datalen; z++) {
29888                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
29889                 *ret_conv_25_conv = ret_var.data[z];
29890                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
29891         }
29892         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29893         FREE(ret_var.data);
29894         return ret_arr;
29895 }
29896
29897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
29898         LDKChannelMonitor this_arg_conv;
29899         this_arg_conv.inner = untag_ptr(this_arg);
29900         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29902         this_arg_conv.is_owned = false;
29903         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
29904         int64_t ret_ref = 0;
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29907         return ret_ref;
29908 }
29909
29910 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
29911         LDKChannelMonitor this_arg_conv;
29912         this_arg_conv.inner = untag_ptr(this_arg);
29913         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29915         this_arg_conv.is_owned = false;
29916         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
29917         int64_tArray ret_arr = NULL;
29918         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29919         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29920         for (size_t j = 0; j < ret_var.datalen; j++) {
29921                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29922                 *ret_conv_9_copy = ret_var.data[j];
29923                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
29924                 ret_arr_ptr[j] = ret_conv_9_ref;
29925         }
29926         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29927         FREE(ret_var.data);
29928         return ret_arr;
29929 }
29930
29931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
29932         LDKu8slice ser_ref;
29933         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29934         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29935         void* arg_ptr = untag_ptr(arg);
29936         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
29937         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
29938         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
29939         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
29940         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29941         return tag_ptr(ret_conv, true);
29942 }
29943
29944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29945         LDKOutPoint this_obj_conv;
29946         this_obj_conv.inner = untag_ptr(this_obj);
29947         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29949         OutPoint_free(this_obj_conv);
29950 }
29951
29952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29953         LDKOutPoint this_ptr_conv;
29954         this_ptr_conv.inner = untag_ptr(this_ptr);
29955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29957         this_ptr_conv.is_owned = false;
29958         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
29960         return ret_arr;
29961 }
29962
29963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29964         LDKOutPoint this_ptr_conv;
29965         this_ptr_conv.inner = untag_ptr(this_ptr);
29966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29968         this_ptr_conv.is_owned = false;
29969         LDKThirtyTwoBytes val_ref;
29970         CHECK((*env)->GetArrayLength(env, val) == 32);
29971         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29972         OutPoint_set_txid(&this_ptr_conv, val_ref);
29973 }
29974
29975 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
29976         LDKOutPoint this_ptr_conv;
29977         this_ptr_conv.inner = untag_ptr(this_ptr);
29978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29980         this_ptr_conv.is_owned = false;
29981         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
29982         return ret_conv;
29983 }
29984
29985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29986         LDKOutPoint this_ptr_conv;
29987         this_ptr_conv.inner = untag_ptr(this_ptr);
29988         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29990         this_ptr_conv.is_owned = false;
29991         OutPoint_set_index(&this_ptr_conv, val);
29992 }
29993
29994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
29995         LDKThirtyTwoBytes txid_arg_ref;
29996         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
29997         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
29998         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
29999         int64_t ret_ref = 0;
30000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30002         return ret_ref;
30003 }
30004
30005 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
30006         LDKOutPoint ret_var = OutPoint_clone(arg);
30007         int64_t ret_ref = 0;
30008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30009         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30010         return ret_ref;
30011 }
30012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30013         LDKOutPoint arg_conv;
30014         arg_conv.inner = untag_ptr(arg);
30015         arg_conv.is_owned = ptr_is_owned(arg);
30016         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30017         arg_conv.is_owned = false;
30018         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
30019         return ret_conv;
30020 }
30021
30022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30023         LDKOutPoint orig_conv;
30024         orig_conv.inner = untag_ptr(orig);
30025         orig_conv.is_owned = ptr_is_owned(orig);
30026         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30027         orig_conv.is_owned = false;
30028         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
30029         int64_t ret_ref = 0;
30030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30031         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30032         return ret_ref;
30033 }
30034
30035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30036         LDKOutPoint a_conv;
30037         a_conv.inner = untag_ptr(a);
30038         a_conv.is_owned = ptr_is_owned(a);
30039         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30040         a_conv.is_owned = false;
30041         LDKOutPoint b_conv;
30042         b_conv.inner = untag_ptr(b);
30043         b_conv.is_owned = ptr_is_owned(b);
30044         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30045         b_conv.is_owned = false;
30046         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
30047         return ret_conv;
30048 }
30049
30050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
30051         LDKOutPoint o_conv;
30052         o_conv.inner = untag_ptr(o);
30053         o_conv.is_owned = ptr_is_owned(o);
30054         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30055         o_conv.is_owned = false;
30056         int64_t ret_conv = OutPoint_hash(&o_conv);
30057         return ret_conv;
30058 }
30059
30060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30061         LDKOutPoint this_arg_conv;
30062         this_arg_conv.inner = untag_ptr(this_arg);
30063         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30065         this_arg_conv.is_owned = false;
30066         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
30068         return ret_arr;
30069 }
30070
30071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
30072         LDKOutPoint obj_conv;
30073         obj_conv.inner = untag_ptr(obj);
30074         obj_conv.is_owned = ptr_is_owned(obj);
30075         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30076         obj_conv.is_owned = false;
30077         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
30078         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30079         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30080         CVec_u8Z_free(ret_var);
30081         return ret_arr;
30082 }
30083
30084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30085         LDKu8slice ser_ref;
30086         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30087         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30088         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
30089         *ret_conv = OutPoint_read(ser_ref);
30090         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30091         return tag_ptr(ret_conv, true);
30092 }
30093
30094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30095         LDKDelayedPaymentOutputDescriptor this_obj_conv;
30096         this_obj_conv.inner = untag_ptr(this_obj);
30097         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30099         DelayedPaymentOutputDescriptor_free(this_obj_conv);
30100 }
30101
30102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30103         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30104         this_ptr_conv.inner = untag_ptr(this_ptr);
30105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30107         this_ptr_conv.is_owned = false;
30108         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30109         int64_t ret_ref = 0;
30110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30111         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30112         return ret_ref;
30113 }
30114
30115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30116         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30117         this_ptr_conv.inner = untag_ptr(this_ptr);
30118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30120         this_ptr_conv.is_owned = false;
30121         LDKOutPoint val_conv;
30122         val_conv.inner = untag_ptr(val);
30123         val_conv.is_owned = ptr_is_owned(val);
30124         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30125         val_conv = OutPoint_clone(&val_conv);
30126         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30127 }
30128
30129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30130         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30131         this_ptr_conv.inner = untag_ptr(this_ptr);
30132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30134         this_ptr_conv.is_owned = false;
30135         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
30137         return ret_arr;
30138 }
30139
30140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30141         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30142         this_ptr_conv.inner = untag_ptr(this_ptr);
30143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30145         this_ptr_conv.is_owned = false;
30146         LDKPublicKey val_ref;
30147         CHECK((*env)->GetArrayLength(env, val) == 33);
30148         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30149         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
30150 }
30151
30152 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30153         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30154         this_ptr_conv.inner = untag_ptr(this_ptr);
30155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30157         this_ptr_conv.is_owned = false;
30158         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
30159         return ret_conv;
30160 }
30161
30162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30163         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30164         this_ptr_conv.inner = untag_ptr(this_ptr);
30165         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30167         this_ptr_conv.is_owned = false;
30168         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
30169 }
30170
30171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30172         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30173         this_ptr_conv.inner = untag_ptr(this_ptr);
30174         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30176         this_ptr_conv.is_owned = false;
30177         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30178         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
30179         return tag_ptr(ret_ref, true);
30180 }
30181
30182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30183         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30184         this_ptr_conv.inner = untag_ptr(this_ptr);
30185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30187         this_ptr_conv.is_owned = false;
30188         void* val_ptr = untag_ptr(val);
30189         CHECK_ACCESS(val_ptr);
30190         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30191         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30192         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30193 }
30194
30195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30196         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30197         this_ptr_conv.inner = untag_ptr(this_ptr);
30198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30200         this_ptr_conv.is_owned = false;
30201         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
30203         return ret_arr;
30204 }
30205
30206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30207         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30208         this_ptr_conv.inner = untag_ptr(this_ptr);
30209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30211         this_ptr_conv.is_owned = false;
30212         LDKPublicKey val_ref;
30213         CHECK((*env)->GetArrayLength(env, val) == 33);
30214         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30215         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
30216 }
30217
30218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30219         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30220         this_ptr_conv.inner = untag_ptr(this_ptr);
30221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30223         this_ptr_conv.is_owned = false;
30224         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30226         return ret_arr;
30227 }
30228
30229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30230         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30231         this_ptr_conv.inner = untag_ptr(this_ptr);
30232         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30234         this_ptr_conv.is_owned = false;
30235         LDKThirtyTwoBytes val_ref;
30236         CHECK((*env)->GetArrayLength(env, val) == 32);
30237         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30238         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30239 }
30240
30241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30242         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30243         this_ptr_conv.inner = untag_ptr(this_ptr);
30244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30246         this_ptr_conv.is_owned = false;
30247         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30248         return ret_conv;
30249 }
30250
30251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30252         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30253         this_ptr_conv.inner = untag_ptr(this_ptr);
30254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30256         this_ptr_conv.is_owned = false;
30257         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30258 }
30259
30260 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) {
30261         LDKOutPoint outpoint_arg_conv;
30262         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30263         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30264         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30265         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30266         LDKPublicKey per_commitment_point_arg_ref;
30267         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
30268         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
30269         void* output_arg_ptr = untag_ptr(output_arg);
30270         CHECK_ACCESS(output_arg_ptr);
30271         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30272         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30273         LDKPublicKey revocation_pubkey_arg_ref;
30274         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
30275         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
30276         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30277         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30278         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30279         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);
30280         int64_t ret_ref = 0;
30281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30283         return ret_ref;
30284 }
30285
30286 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
30287         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
30288         int64_t ret_ref = 0;
30289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30291         return ret_ref;
30292 }
30293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30294         LDKDelayedPaymentOutputDescriptor arg_conv;
30295         arg_conv.inner = untag_ptr(arg);
30296         arg_conv.is_owned = ptr_is_owned(arg);
30297         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30298         arg_conv.is_owned = false;
30299         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
30300         return ret_conv;
30301 }
30302
30303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30304         LDKDelayedPaymentOutputDescriptor orig_conv;
30305         orig_conv.inner = untag_ptr(orig);
30306         orig_conv.is_owned = ptr_is_owned(orig);
30307         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30308         orig_conv.is_owned = false;
30309         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
30310         int64_t ret_ref = 0;
30311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30313         return ret_ref;
30314 }
30315
30316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30317         LDKDelayedPaymentOutputDescriptor a_conv;
30318         a_conv.inner = untag_ptr(a);
30319         a_conv.is_owned = ptr_is_owned(a);
30320         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30321         a_conv.is_owned = false;
30322         LDKDelayedPaymentOutputDescriptor b_conv;
30323         b_conv.inner = untag_ptr(b);
30324         b_conv.is_owned = ptr_is_owned(b);
30325         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30326         b_conv.is_owned = false;
30327         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30328         return ret_conv;
30329 }
30330
30331 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30332         LDKDelayedPaymentOutputDescriptor obj_conv;
30333         obj_conv.inner = untag_ptr(obj);
30334         obj_conv.is_owned = ptr_is_owned(obj);
30335         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30336         obj_conv.is_owned = false;
30337         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
30338         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30339         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30340         CVec_u8Z_free(ret_var);
30341         return ret_arr;
30342 }
30343
30344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30345         LDKu8slice ser_ref;
30346         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30347         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30348         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
30349         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
30350         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30351         return tag_ptr(ret_conv, true);
30352 }
30353
30354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30355         LDKStaticPaymentOutputDescriptor this_obj_conv;
30356         this_obj_conv.inner = untag_ptr(this_obj);
30357         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30359         StaticPaymentOutputDescriptor_free(this_obj_conv);
30360 }
30361
30362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30363         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30364         this_ptr_conv.inner = untag_ptr(this_ptr);
30365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30367         this_ptr_conv.is_owned = false;
30368         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30369         int64_t ret_ref = 0;
30370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30372         return ret_ref;
30373 }
30374
30375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30376         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30377         this_ptr_conv.inner = untag_ptr(this_ptr);
30378         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30380         this_ptr_conv.is_owned = false;
30381         LDKOutPoint val_conv;
30382         val_conv.inner = untag_ptr(val);
30383         val_conv.is_owned = ptr_is_owned(val);
30384         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30385         val_conv = OutPoint_clone(&val_conv);
30386         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30387 }
30388
30389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30390         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30391         this_ptr_conv.inner = untag_ptr(this_ptr);
30392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30394         this_ptr_conv.is_owned = false;
30395         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30396         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
30397         return tag_ptr(ret_ref, true);
30398 }
30399
30400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30401         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30402         this_ptr_conv.inner = untag_ptr(this_ptr);
30403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30405         this_ptr_conv.is_owned = false;
30406         void* val_ptr = untag_ptr(val);
30407         CHECK_ACCESS(val_ptr);
30408         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30409         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30410         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30411 }
30412
30413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30414         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30415         this_ptr_conv.inner = untag_ptr(this_ptr);
30416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30418         this_ptr_conv.is_owned = false;
30419         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30420         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30421         return ret_arr;
30422 }
30423
30424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30425         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30426         this_ptr_conv.inner = untag_ptr(this_ptr);
30427         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30429         this_ptr_conv.is_owned = false;
30430         LDKThirtyTwoBytes val_ref;
30431         CHECK((*env)->GetArrayLength(env, val) == 32);
30432         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30433         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30434 }
30435
30436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30437         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30438         this_ptr_conv.inner = untag_ptr(this_ptr);
30439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30441         this_ptr_conv.is_owned = false;
30442         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30443         return ret_conv;
30444 }
30445
30446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30447         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30448         this_ptr_conv.inner = untag_ptr(this_ptr);
30449         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30451         this_ptr_conv.is_owned = false;
30452         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30453 }
30454
30455 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) {
30456         LDKOutPoint outpoint_arg_conv;
30457         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30458         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30459         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30460         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30461         void* output_arg_ptr = untag_ptr(output_arg);
30462         CHECK_ACCESS(output_arg_ptr);
30463         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30464         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30465         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30466         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30467         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30468         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
30469         int64_t ret_ref = 0;
30470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30472         return ret_ref;
30473 }
30474
30475 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
30476         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
30477         int64_t ret_ref = 0;
30478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30480         return ret_ref;
30481 }
30482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30483         LDKStaticPaymentOutputDescriptor arg_conv;
30484         arg_conv.inner = untag_ptr(arg);
30485         arg_conv.is_owned = ptr_is_owned(arg);
30486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30487         arg_conv.is_owned = false;
30488         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
30489         return ret_conv;
30490 }
30491
30492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30493         LDKStaticPaymentOutputDescriptor orig_conv;
30494         orig_conv.inner = untag_ptr(orig);
30495         orig_conv.is_owned = ptr_is_owned(orig);
30496         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30497         orig_conv.is_owned = false;
30498         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
30499         int64_t ret_ref = 0;
30500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30501         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30502         return ret_ref;
30503 }
30504
30505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30506         LDKStaticPaymentOutputDescriptor a_conv;
30507         a_conv.inner = untag_ptr(a);
30508         a_conv.is_owned = ptr_is_owned(a);
30509         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30510         a_conv.is_owned = false;
30511         LDKStaticPaymentOutputDescriptor b_conv;
30512         b_conv.inner = untag_ptr(b);
30513         b_conv.is_owned = ptr_is_owned(b);
30514         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30515         b_conv.is_owned = false;
30516         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30517         return ret_conv;
30518 }
30519
30520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30521         LDKStaticPaymentOutputDescriptor obj_conv;
30522         obj_conv.inner = untag_ptr(obj);
30523         obj_conv.is_owned = ptr_is_owned(obj);
30524         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30525         obj_conv.is_owned = false;
30526         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
30527         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30528         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30529         CVec_u8Z_free(ret_var);
30530         return ret_arr;
30531 }
30532
30533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30534         LDKu8slice ser_ref;
30535         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30536         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30537         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
30538         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
30539         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30540         return tag_ptr(ret_conv, true);
30541 }
30542
30543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30544         if (!ptr_is_owned(this_ptr)) return;
30545         void* this_ptr_ptr = untag_ptr(this_ptr);
30546         CHECK_ACCESS(this_ptr_ptr);
30547         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
30548         FREE(untag_ptr(this_ptr));
30549         SpendableOutputDescriptor_free(this_ptr_conv);
30550 }
30551
30552 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
30553         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30554         *ret_copy = SpendableOutputDescriptor_clone(arg);
30555         int64_t ret_ref = tag_ptr(ret_copy, true);
30556         return ret_ref;
30557 }
30558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30559         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
30560         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
30561         return ret_conv;
30562 }
30563
30564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30565         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
30566         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30567         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
30568         int64_t ret_ref = tag_ptr(ret_copy, true);
30569         return ret_ref;
30570 }
30571
30572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
30573         LDKOutPoint outpoint_conv;
30574         outpoint_conv.inner = untag_ptr(outpoint);
30575         outpoint_conv.is_owned = ptr_is_owned(outpoint);
30576         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
30577         outpoint_conv = OutPoint_clone(&outpoint_conv);
30578         void* output_ptr = untag_ptr(output);
30579         CHECK_ACCESS(output_ptr);
30580         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
30581         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
30582         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30583         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
30584         int64_t ret_ref = tag_ptr(ret_copy, true);
30585         return ret_ref;
30586 }
30587
30588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30589         LDKDelayedPaymentOutputDescriptor a_conv;
30590         a_conv.inner = untag_ptr(a);
30591         a_conv.is_owned = ptr_is_owned(a);
30592         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30593         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
30594         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30595         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
30596         int64_t ret_ref = tag_ptr(ret_copy, true);
30597         return ret_ref;
30598 }
30599
30600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30601         LDKStaticPaymentOutputDescriptor a_conv;
30602         a_conv.inner = untag_ptr(a);
30603         a_conv.is_owned = ptr_is_owned(a);
30604         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30605         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
30606         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30607         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
30608         int64_t ret_ref = tag_ptr(ret_copy, true);
30609         return ret_ref;
30610 }
30611
30612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30613         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
30614         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
30615         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
30616         return ret_conv;
30617 }
30618
30619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30620         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
30621         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
30622         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30623         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30624         CVec_u8Z_free(ret_var);
30625         return ret_arr;
30626 }
30627
30628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30629         LDKu8slice ser_ref;
30630         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30631         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30632         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
30633         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
30634         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30635         return tag_ptr(ret_conv, true);
30636 }
30637
30638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30639         if (!ptr_is_owned(this_ptr)) return;
30640         void* this_ptr_ptr = untag_ptr(this_ptr);
30641         CHECK_ACCESS(this_ptr_ptr);
30642         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
30643         FREE(untag_ptr(this_ptr));
30644         BaseSign_free(this_ptr_conv);
30645 }
30646
30647 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
30648         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
30649         *ret_ret = Sign_clone(arg);
30650         return tag_ptr(ret_ret, true);
30651 }
30652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30653         void* arg_ptr = untag_ptr(arg);
30654         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
30655         LDKSign* arg_conv = (LDKSign*)arg_ptr;
30656         int64_t ret_conv = Sign_clone_ptr(arg_conv);
30657         return ret_conv;
30658 }
30659
30660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30661         void* orig_ptr = untag_ptr(orig);
30662         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
30663         LDKSign* orig_conv = (LDKSign*)orig_ptr;
30664         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
30665         *ret_ret = Sign_clone(orig_conv);
30666         return tag_ptr(ret_ret, true);
30667 }
30668
30669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30670         if (!ptr_is_owned(this_ptr)) return;
30671         void* this_ptr_ptr = untag_ptr(this_ptr);
30672         CHECK_ACCESS(this_ptr_ptr);
30673         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
30674         FREE(untag_ptr(this_ptr));
30675         Sign_free(this_ptr_conv);
30676 }
30677
30678 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30679         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
30680         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
30681         return ret_conv;
30682 }
30683
30684 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
30685         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
30686         return ret_conv;
30687 }
30688
30689 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
30690         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
30691         return ret_conv;
30692 }
30693
30694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30695         if (!ptr_is_owned(this_ptr)) return;
30696         void* this_ptr_ptr = untag_ptr(this_ptr);
30697         CHECK_ACCESS(this_ptr_ptr);
30698         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
30699         FREE(untag_ptr(this_ptr));
30700         KeysInterface_free(this_ptr_conv);
30701 }
30702
30703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30704         LDKInMemorySigner this_obj_conv;
30705         this_obj_conv.inner = untag_ptr(this_obj);
30706         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30708         InMemorySigner_free(this_obj_conv);
30709 }
30710
30711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30712         LDKInMemorySigner this_ptr_conv;
30713         this_ptr_conv.inner = untag_ptr(this_ptr);
30714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30716         this_ptr_conv.is_owned = false;
30717         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30718         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
30719         return ret_arr;
30720 }
30721
30722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30723         LDKInMemorySigner this_ptr_conv;
30724         this_ptr_conv.inner = untag_ptr(this_ptr);
30725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30727         this_ptr_conv.is_owned = false;
30728         LDKSecretKey val_ref;
30729         CHECK((*env)->GetArrayLength(env, val) == 32);
30730         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30731         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
30732 }
30733
30734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30735         LDKInMemorySigner this_ptr_conv;
30736         this_ptr_conv.inner = untag_ptr(this_ptr);
30737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30739         this_ptr_conv.is_owned = false;
30740         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30741         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
30742         return ret_arr;
30743 }
30744
30745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30746         LDKInMemorySigner this_ptr_conv;
30747         this_ptr_conv.inner = untag_ptr(this_ptr);
30748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30750         this_ptr_conv.is_owned = false;
30751         LDKSecretKey val_ref;
30752         CHECK((*env)->GetArrayLength(env, val) == 32);
30753         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30754         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
30755 }
30756
30757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30758         LDKInMemorySigner this_ptr_conv;
30759         this_ptr_conv.inner = untag_ptr(this_ptr);
30760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30762         this_ptr_conv.is_owned = false;
30763         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30764         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
30765         return ret_arr;
30766 }
30767
30768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30769         LDKInMemorySigner this_ptr_conv;
30770         this_ptr_conv.inner = untag_ptr(this_ptr);
30771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30773         this_ptr_conv.is_owned = false;
30774         LDKSecretKey val_ref;
30775         CHECK((*env)->GetArrayLength(env, val) == 32);
30776         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30777         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
30778 }
30779
30780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30781         LDKInMemorySigner this_ptr_conv;
30782         this_ptr_conv.inner = untag_ptr(this_ptr);
30783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30785         this_ptr_conv.is_owned = false;
30786         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
30788         return ret_arr;
30789 }
30790
30791 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) {
30792         LDKInMemorySigner this_ptr_conv;
30793         this_ptr_conv.inner = untag_ptr(this_ptr);
30794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30796         this_ptr_conv.is_owned = false;
30797         LDKSecretKey val_ref;
30798         CHECK((*env)->GetArrayLength(env, val) == 32);
30799         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30800         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
30801 }
30802
30803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30804         LDKInMemorySigner this_ptr_conv;
30805         this_ptr_conv.inner = untag_ptr(this_ptr);
30806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30808         this_ptr_conv.is_owned = false;
30809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
30811         return ret_arr;
30812 }
30813
30814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30815         LDKInMemorySigner this_ptr_conv;
30816         this_ptr_conv.inner = untag_ptr(this_ptr);
30817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30819         this_ptr_conv.is_owned = false;
30820         LDKSecretKey val_ref;
30821         CHECK((*env)->GetArrayLength(env, val) == 32);
30822         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30823         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
30824 }
30825
30826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
30827         LDKInMemorySigner this_ptr_conv;
30828         this_ptr_conv.inner = untag_ptr(this_ptr);
30829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30831         this_ptr_conv.is_owned = false;
30832         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30833         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
30834         return ret_arr;
30835 }
30836
30837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30838         LDKInMemorySigner this_ptr_conv;
30839         this_ptr_conv.inner = untag_ptr(this_ptr);
30840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30842         this_ptr_conv.is_owned = false;
30843         LDKThirtyTwoBytes val_ref;
30844         CHECK((*env)->GetArrayLength(env, val) == 32);
30845         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30846         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
30847 }
30848
30849 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
30850         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
30851         int64_t ret_ref = 0;
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30853         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30854         return ret_ref;
30855 }
30856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30857         LDKInMemorySigner arg_conv;
30858         arg_conv.inner = untag_ptr(arg);
30859         arg_conv.is_owned = ptr_is_owned(arg);
30860         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30861         arg_conv.is_owned = false;
30862         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
30863         return ret_conv;
30864 }
30865
30866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30867         LDKInMemorySigner orig_conv;
30868         orig_conv.inner = untag_ptr(orig);
30869         orig_conv.is_owned = ptr_is_owned(orig);
30870         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30871         orig_conv.is_owned = false;
30872         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
30873         int64_t ret_ref = 0;
30874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30876         return ret_ref;
30877 }
30878
30879 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) {
30880         LDKSecretKey node_secret_ref;
30881         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
30882         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
30883         LDKSecretKey funding_key_ref;
30884         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
30885         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
30886         LDKSecretKey revocation_base_key_ref;
30887         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
30888         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
30889         LDKSecretKey payment_key_ref;
30890         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
30891         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
30892         LDKSecretKey delayed_payment_base_key_ref;
30893         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
30894         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
30895         LDKSecretKey htlc_base_key_ref;
30896         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
30897         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
30898         LDKThirtyTwoBytes commitment_seed_ref;
30899         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
30900         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
30901         LDKThirtyTwoBytes channel_keys_id_ref;
30902         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
30903         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
30904         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);
30905         int64_t ret_ref = 0;
30906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30908         return ret_ref;
30909 }
30910
30911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
30912         LDKInMemorySigner this_arg_conv;
30913         this_arg_conv.inner = untag_ptr(this_arg);
30914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30916         this_arg_conv.is_owned = false;
30917         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
30918         int64_t ret_ref = 0;
30919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30920         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30921         return ret_ref;
30922 }
30923
30924 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
30925         LDKInMemorySigner this_arg_conv;
30926         this_arg_conv.inner = untag_ptr(this_arg);
30927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30929         this_arg_conv.is_owned = false;
30930         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
30931         return ret_conv;
30932 }
30933
30934 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
30935         LDKInMemorySigner this_arg_conv;
30936         this_arg_conv.inner = untag_ptr(this_arg);
30937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30939         this_arg_conv.is_owned = false;
30940         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
30941         return ret_conv;
30942 }
30943
30944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
30945         LDKInMemorySigner this_arg_conv;
30946         this_arg_conv.inner = untag_ptr(this_arg);
30947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30949         this_arg_conv.is_owned = false;
30950         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
30951         return ret_conv;
30952 }
30953
30954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
30955         LDKInMemorySigner this_arg_conv;
30956         this_arg_conv.inner = untag_ptr(this_arg);
30957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30959         this_arg_conv.is_owned = false;
30960         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
30961         int64_t ret_ref = 0;
30962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30964         return ret_ref;
30965 }
30966
30967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
30968         LDKInMemorySigner this_arg_conv;
30969         this_arg_conv.inner = untag_ptr(this_arg);
30970         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30972         this_arg_conv.is_owned = false;
30973         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
30974         int64_t ret_ref = 0;
30975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30977         return ret_ref;
30978 }
30979
30980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
30981         LDKInMemorySigner this_arg_conv;
30982         this_arg_conv.inner = untag_ptr(this_arg);
30983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30985         this_arg_conv.is_owned = false;
30986         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
30987         return ret_conv;
30988 }
30989
30990 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) {
30991         LDKInMemorySigner this_arg_conv;
30992         this_arg_conv.inner = untag_ptr(this_arg);
30993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30995         this_arg_conv.is_owned = false;
30996         LDKTransaction spend_tx_ref;
30997         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
30998         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
30999         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31000         spend_tx_ref.data_is_owned = true;
31001         LDKStaticPaymentOutputDescriptor descriptor_conv;
31002         descriptor_conv.inner = untag_ptr(descriptor);
31003         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31004         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31005         descriptor_conv.is_owned = false;
31006         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31007         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31008         return tag_ptr(ret_conv, true);
31009 }
31010
31011 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) {
31012         LDKInMemorySigner this_arg_conv;
31013         this_arg_conv.inner = untag_ptr(this_arg);
31014         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31016         this_arg_conv.is_owned = false;
31017         LDKTransaction spend_tx_ref;
31018         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31019         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31020         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31021         spend_tx_ref.data_is_owned = true;
31022         LDKDelayedPaymentOutputDescriptor descriptor_conv;
31023         descriptor_conv.inner = untag_ptr(descriptor);
31024         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31025         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31026         descriptor_conv.is_owned = false;
31027         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31028         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31029         return tag_ptr(ret_conv, true);
31030 }
31031
31032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
31033         LDKInMemorySigner this_arg_conv;
31034         this_arg_conv.inner = untag_ptr(this_arg);
31035         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31037         this_arg_conv.is_owned = false;
31038         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
31039         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
31040         return tag_ptr(ret_ret, true);
31041 }
31042
31043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
31044         LDKInMemorySigner this_arg_conv;
31045         this_arg_conv.inner = untag_ptr(this_arg);
31046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31048         this_arg_conv.is_owned = false;
31049         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
31050         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
31051         return tag_ptr(ret_ret, true);
31052 }
31053
31054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
31055         LDKInMemorySigner obj_conv;
31056         obj_conv.inner = untag_ptr(obj);
31057         obj_conv.is_owned = ptr_is_owned(obj);
31058         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31059         obj_conv.is_owned = false;
31060         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
31061         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31062         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31063         CVec_u8Z_free(ret_var);
31064         return ret_arr;
31065 }
31066
31067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
31068         LDKu8slice ser_ref;
31069         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31070         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31071         LDKSecretKey arg_ref;
31072         CHECK((*env)->GetArrayLength(env, arg) == 32);
31073         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
31074         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
31075         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
31076         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31077         return tag_ptr(ret_conv, true);
31078 }
31079
31080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31081         LDKKeysManager this_obj_conv;
31082         this_obj_conv.inner = untag_ptr(this_obj);
31083         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31085         KeysManager_free(this_obj_conv);
31086 }
31087
31088 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) {
31089         unsigned char seed_arr[32];
31090         CHECK((*env)->GetArrayLength(env, seed) == 32);
31091         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31092         unsigned char (*seed_ref)[32] = &seed_arr;
31093         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
31094         int64_t ret_ref = 0;
31095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31097         return ret_ref;
31098 }
31099
31100 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) {
31101         LDKKeysManager this_arg_conv;
31102         this_arg_conv.inner = untag_ptr(this_arg);
31103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31105         this_arg_conv.is_owned = false;
31106         unsigned char params_arr[32];
31107         CHECK((*env)->GetArrayLength(env, params) == 32);
31108         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31109         unsigned char (*params_ref)[32] = &params_arr;
31110         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31111         int64_t ret_ref = 0;
31112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31114         return ret_ref;
31115 }
31116
31117 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) {
31118         LDKKeysManager this_arg_conv;
31119         this_arg_conv.inner = untag_ptr(this_arg);
31120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31122         this_arg_conv.is_owned = false;
31123         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31124         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31125         if (descriptors_constr.datalen > 0)
31126                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31127         else
31128                 descriptors_constr.data = NULL;
31129         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31130         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31131                 int64_t descriptors_conv_27 = descriptors_vals[b];
31132                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31133                 CHECK_ACCESS(descriptors_conv_27_ptr);
31134                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31135                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31136                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31137         }
31138         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31139         LDKCVec_TxOutZ outputs_constr;
31140         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31141         if (outputs_constr.datalen > 0)
31142                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31143         else
31144                 outputs_constr.data = NULL;
31145         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31146         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31147                 int64_t outputs_conv_7 = outputs_vals[h];
31148                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31149                 CHECK_ACCESS(outputs_conv_7_ptr);
31150                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31151                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31152                 outputs_constr.data[h] = outputs_conv_7_conv;
31153         }
31154         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31155         LDKCVec_u8Z change_destination_script_ref;
31156         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31157         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31158         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31159         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31160         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31161         return tag_ptr(ret_conv, true);
31162 }
31163
31164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
31165         LDKKeysManager this_arg_conv;
31166         this_arg_conv.inner = untag_ptr(this_arg);
31167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31169         this_arg_conv.is_owned = false;
31170         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
31171         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
31172         return tag_ptr(ret_ret, true);
31173 }
31174
31175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31176         LDKPhantomKeysManager this_obj_conv;
31177         this_obj_conv.inner = untag_ptr(this_obj);
31178         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31180         PhantomKeysManager_free(this_obj_conv);
31181 }
31182
31183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
31184         LDKPhantomKeysManager this_arg_conv;
31185         this_arg_conv.inner = untag_ptr(this_arg);
31186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31188         this_arg_conv.is_owned = false;
31189         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
31190         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
31191         return tag_ptr(ret_ret, true);
31192 }
31193
31194 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) {
31195         unsigned char seed_arr[32];
31196         CHECK((*env)->GetArrayLength(env, seed) == 32);
31197         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31198         unsigned char (*seed_ref)[32] = &seed_arr;
31199         unsigned char cross_node_seed_arr[32];
31200         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
31201         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
31202         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
31203         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
31204         int64_t ret_ref = 0;
31205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31207         return ret_ref;
31208 }
31209
31210 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) {
31211         LDKPhantomKeysManager this_arg_conv;
31212         this_arg_conv.inner = untag_ptr(this_arg);
31213         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31215         this_arg_conv.is_owned = false;
31216         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31217         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31218         if (descriptors_constr.datalen > 0)
31219                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31220         else
31221                 descriptors_constr.data = NULL;
31222         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31223         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31224                 int64_t descriptors_conv_27 = descriptors_vals[b];
31225                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31226                 CHECK_ACCESS(descriptors_conv_27_ptr);
31227                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31228                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31229                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31230         }
31231         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31232         LDKCVec_TxOutZ outputs_constr;
31233         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31234         if (outputs_constr.datalen > 0)
31235                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31236         else
31237                 outputs_constr.data = NULL;
31238         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31239         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31240                 int64_t outputs_conv_7 = outputs_vals[h];
31241                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31242                 CHECK_ACCESS(outputs_conv_7_ptr);
31243                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31244                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31245                 outputs_constr.data[h] = outputs_conv_7_conv;
31246         }
31247         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31248         LDKCVec_u8Z change_destination_script_ref;
31249         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31250         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31251         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31252         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31253         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31254         return tag_ptr(ret_conv, true);
31255 }
31256
31257 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) {
31258         LDKPhantomKeysManager this_arg_conv;
31259         this_arg_conv.inner = untag_ptr(this_arg);
31260         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31262         this_arg_conv.is_owned = false;
31263         unsigned char params_arr[32];
31264         CHECK((*env)->GetArrayLength(env, params) == 32);
31265         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31266         unsigned char (*params_ref)[32] = &params_arr;
31267         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31268         int64_t ret_ref = 0;
31269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31270         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31271         return ret_ref;
31272 }
31273
31274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31275         LDKChannelManager this_obj_conv;
31276         this_obj_conv.inner = untag_ptr(this_obj);
31277         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31279         ChannelManager_free(this_obj_conv);
31280 }
31281
31282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31283         LDKChainParameters this_obj_conv;
31284         this_obj_conv.inner = untag_ptr(this_obj);
31285         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31287         ChainParameters_free(this_obj_conv);
31288 }
31289
31290 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
31291         LDKChainParameters this_ptr_conv;
31292         this_ptr_conv.inner = untag_ptr(this_ptr);
31293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31295         this_ptr_conv.is_owned = false;
31296         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
31297         return ret_conv;
31298 }
31299
31300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
31301         LDKChainParameters this_ptr_conv;
31302         this_ptr_conv.inner = untag_ptr(this_ptr);
31303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31305         this_ptr_conv.is_owned = false;
31306         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
31307         ChainParameters_set_network(&this_ptr_conv, val_conv);
31308 }
31309
31310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
31311         LDKChainParameters this_ptr_conv;
31312         this_ptr_conv.inner = untag_ptr(this_ptr);
31313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31315         this_ptr_conv.is_owned = false;
31316         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
31317         int64_t ret_ref = 0;
31318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31320         return ret_ref;
31321 }
31322
31323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31324         LDKChainParameters this_ptr_conv;
31325         this_ptr_conv.inner = untag_ptr(this_ptr);
31326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31328         this_ptr_conv.is_owned = false;
31329         LDKBestBlock val_conv;
31330         val_conv.inner = untag_ptr(val);
31331         val_conv.is_owned = ptr_is_owned(val);
31332         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31333         val_conv = BestBlock_clone(&val_conv);
31334         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
31335 }
31336
31337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
31338         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
31339         LDKBestBlock best_block_arg_conv;
31340         best_block_arg_conv.inner = untag_ptr(best_block_arg);
31341         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
31342         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
31343         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
31344         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
31345         int64_t ret_ref = 0;
31346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31348         return ret_ref;
31349 }
31350
31351 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
31352         LDKChainParameters ret_var = ChainParameters_clone(arg);
31353         int64_t ret_ref = 0;
31354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31355         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31356         return ret_ref;
31357 }
31358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31359         LDKChainParameters arg_conv;
31360         arg_conv.inner = untag_ptr(arg);
31361         arg_conv.is_owned = ptr_is_owned(arg);
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31363         arg_conv.is_owned = false;
31364         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
31365         return ret_conv;
31366 }
31367
31368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31369         LDKChainParameters orig_conv;
31370         orig_conv.inner = untag_ptr(orig);
31371         orig_conv.is_owned = ptr_is_owned(orig);
31372         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31373         orig_conv.is_owned = false;
31374         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
31375         int64_t ret_ref = 0;
31376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31378         return ret_ref;
31379 }
31380
31381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31382         LDKCounterpartyForwardingInfo this_obj_conv;
31383         this_obj_conv.inner = untag_ptr(this_obj);
31384         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31386         CounterpartyForwardingInfo_free(this_obj_conv);
31387 }
31388
31389 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31390         LDKCounterpartyForwardingInfo this_ptr_conv;
31391         this_ptr_conv.inner = untag_ptr(this_ptr);
31392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31394         this_ptr_conv.is_owned = false;
31395         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
31396         return ret_conv;
31397 }
31398
31399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31400         LDKCounterpartyForwardingInfo this_ptr_conv;
31401         this_ptr_conv.inner = untag_ptr(this_ptr);
31402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31404         this_ptr_conv.is_owned = false;
31405         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
31406 }
31407
31408 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31409         LDKCounterpartyForwardingInfo this_ptr_conv;
31410         this_ptr_conv.inner = untag_ptr(this_ptr);
31411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31413         this_ptr_conv.is_owned = false;
31414         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
31415         return ret_conv;
31416 }
31417
31418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31419         LDKCounterpartyForwardingInfo this_ptr_conv;
31420         this_ptr_conv.inner = untag_ptr(this_ptr);
31421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31423         this_ptr_conv.is_owned = false;
31424         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
31425 }
31426
31427 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31428         LDKCounterpartyForwardingInfo this_ptr_conv;
31429         this_ptr_conv.inner = untag_ptr(this_ptr);
31430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31432         this_ptr_conv.is_owned = false;
31433         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
31434         return ret_conv;
31435 }
31436
31437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31438         LDKCounterpartyForwardingInfo this_ptr_conv;
31439         this_ptr_conv.inner = untag_ptr(this_ptr);
31440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31442         this_ptr_conv.is_owned = false;
31443         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31444 }
31445
31446 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) {
31447         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
31448         int64_t ret_ref = 0;
31449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31451         return ret_ref;
31452 }
31453
31454 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
31455         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
31456         int64_t ret_ref = 0;
31457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31458         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31459         return ret_ref;
31460 }
31461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31462         LDKCounterpartyForwardingInfo arg_conv;
31463         arg_conv.inner = untag_ptr(arg);
31464         arg_conv.is_owned = ptr_is_owned(arg);
31465         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31466         arg_conv.is_owned = false;
31467         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
31468         return ret_conv;
31469 }
31470
31471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31472         LDKCounterpartyForwardingInfo orig_conv;
31473         orig_conv.inner = untag_ptr(orig);
31474         orig_conv.is_owned = ptr_is_owned(orig);
31475         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31476         orig_conv.is_owned = false;
31477         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
31478         int64_t ret_ref = 0;
31479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31481         return ret_ref;
31482 }
31483
31484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31485         LDKChannelCounterparty this_obj_conv;
31486         this_obj_conv.inner = untag_ptr(this_obj);
31487         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31489         ChannelCounterparty_free(this_obj_conv);
31490 }
31491
31492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31493         LDKChannelCounterparty this_ptr_conv;
31494         this_ptr_conv.inner = untag_ptr(this_ptr);
31495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31497         this_ptr_conv.is_owned = false;
31498         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31499         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
31500         return ret_arr;
31501 }
31502
31503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31504         LDKChannelCounterparty this_ptr_conv;
31505         this_ptr_conv.inner = untag_ptr(this_ptr);
31506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31508         this_ptr_conv.is_owned = false;
31509         LDKPublicKey val_ref;
31510         CHECK((*env)->GetArrayLength(env, val) == 33);
31511         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31512         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
31513 }
31514
31515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31516         LDKChannelCounterparty this_ptr_conv;
31517         this_ptr_conv.inner = untag_ptr(this_ptr);
31518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31520         this_ptr_conv.is_owned = false;
31521         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
31522         int64_t ret_ref = 0;
31523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31525         return ret_ref;
31526 }
31527
31528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31529         LDKChannelCounterparty this_ptr_conv;
31530         this_ptr_conv.inner = untag_ptr(this_ptr);
31531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31533         this_ptr_conv.is_owned = false;
31534         LDKInitFeatures val_conv;
31535         val_conv.inner = untag_ptr(val);
31536         val_conv.is_owned = ptr_is_owned(val);
31537         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31538         val_conv = InitFeatures_clone(&val_conv);
31539         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
31540 }
31541
31542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
31543         LDKChannelCounterparty this_ptr_conv;
31544         this_ptr_conv.inner = untag_ptr(this_ptr);
31545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31547         this_ptr_conv.is_owned = false;
31548         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
31549         return ret_conv;
31550 }
31551
31552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31553         LDKChannelCounterparty this_ptr_conv;
31554         this_ptr_conv.inner = untag_ptr(this_ptr);
31555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31557         this_ptr_conv.is_owned = false;
31558         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
31559 }
31560
31561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
31562         LDKChannelCounterparty this_ptr_conv;
31563         this_ptr_conv.inner = untag_ptr(this_ptr);
31564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31566         this_ptr_conv.is_owned = false;
31567         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
31568         int64_t ret_ref = 0;
31569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31570         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31571         return ret_ref;
31572 }
31573
31574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31575         LDKChannelCounterparty this_ptr_conv;
31576         this_ptr_conv.inner = untag_ptr(this_ptr);
31577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31579         this_ptr_conv.is_owned = false;
31580         LDKCounterpartyForwardingInfo val_conv;
31581         val_conv.inner = untag_ptr(val);
31582         val_conv.is_owned = ptr_is_owned(val);
31583         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31584         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
31585         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
31586 }
31587
31588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31589         LDKChannelCounterparty this_ptr_conv;
31590         this_ptr_conv.inner = untag_ptr(this_ptr);
31591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31593         this_ptr_conv.is_owned = false;
31594         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31595         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
31596         int64_t ret_ref = tag_ptr(ret_copy, true);
31597         return ret_ref;
31598 }
31599
31600 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) {
31601         LDKChannelCounterparty this_ptr_conv;
31602         this_ptr_conv.inner = untag_ptr(this_ptr);
31603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31605         this_ptr_conv.is_owned = false;
31606         void* val_ptr = untag_ptr(val);
31607         CHECK_ACCESS(val_ptr);
31608         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31609         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31610         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
31611 }
31612
31613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31614         LDKChannelCounterparty this_ptr_conv;
31615         this_ptr_conv.inner = untag_ptr(this_ptr);
31616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31618         this_ptr_conv.is_owned = false;
31619         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31620         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
31621         int64_t ret_ref = tag_ptr(ret_copy, true);
31622         return ret_ref;
31623 }
31624
31625 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) {
31626         LDKChannelCounterparty this_ptr_conv;
31627         this_ptr_conv.inner = untag_ptr(this_ptr);
31628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31630         this_ptr_conv.is_owned = false;
31631         void* val_ptr = untag_ptr(val);
31632         CHECK_ACCESS(val_ptr);
31633         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31634         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31635         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
31636 }
31637
31638 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) {
31639         LDKPublicKey node_id_arg_ref;
31640         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
31641         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
31642         LDKInitFeatures features_arg_conv;
31643         features_arg_conv.inner = untag_ptr(features_arg);
31644         features_arg_conv.is_owned = ptr_is_owned(features_arg);
31645         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31646         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31647         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
31648         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
31649         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
31650         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
31651         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
31652         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
31653         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
31654         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
31655         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
31656         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
31657         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
31658         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
31659         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
31660         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);
31661         int64_t ret_ref = 0;
31662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31664         return ret_ref;
31665 }
31666
31667 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
31668         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
31669         int64_t ret_ref = 0;
31670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31672         return ret_ref;
31673 }
31674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31675         LDKChannelCounterparty arg_conv;
31676         arg_conv.inner = untag_ptr(arg);
31677         arg_conv.is_owned = ptr_is_owned(arg);
31678         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31679         arg_conv.is_owned = false;
31680         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
31681         return ret_conv;
31682 }
31683
31684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31685         LDKChannelCounterparty orig_conv;
31686         orig_conv.inner = untag_ptr(orig);
31687         orig_conv.is_owned = ptr_is_owned(orig);
31688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31689         orig_conv.is_owned = false;
31690         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
31691         int64_t ret_ref = 0;
31692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31694         return ret_ref;
31695 }
31696
31697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31698         LDKChannelDetails this_obj_conv;
31699         this_obj_conv.inner = untag_ptr(this_obj);
31700         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31702         ChannelDetails_free(this_obj_conv);
31703 }
31704
31705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31706         LDKChannelDetails this_ptr_conv;
31707         this_ptr_conv.inner = untag_ptr(this_ptr);
31708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31710         this_ptr_conv.is_owned = false;
31711         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31712         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
31713         return ret_arr;
31714 }
31715
31716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31717         LDKChannelDetails this_ptr_conv;
31718         this_ptr_conv.inner = untag_ptr(this_ptr);
31719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31721         this_ptr_conv.is_owned = false;
31722         LDKThirtyTwoBytes val_ref;
31723         CHECK((*env)->GetArrayLength(env, val) == 32);
31724         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31725         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
31726 }
31727
31728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
31729         LDKChannelDetails this_ptr_conv;
31730         this_ptr_conv.inner = untag_ptr(this_ptr);
31731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31733         this_ptr_conv.is_owned = false;
31734         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
31735         int64_t ret_ref = 0;
31736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31738         return ret_ref;
31739 }
31740
31741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31742         LDKChannelDetails this_ptr_conv;
31743         this_ptr_conv.inner = untag_ptr(this_ptr);
31744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31746         this_ptr_conv.is_owned = false;
31747         LDKChannelCounterparty val_conv;
31748         val_conv.inner = untag_ptr(val);
31749         val_conv.is_owned = ptr_is_owned(val);
31750         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31751         val_conv = ChannelCounterparty_clone(&val_conv);
31752         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
31753 }
31754
31755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
31756         LDKChannelDetails this_ptr_conv;
31757         this_ptr_conv.inner = untag_ptr(this_ptr);
31758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31760         this_ptr_conv.is_owned = false;
31761         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
31762         int64_t ret_ref = 0;
31763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31765         return ret_ref;
31766 }
31767
31768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31769         LDKChannelDetails this_ptr_conv;
31770         this_ptr_conv.inner = untag_ptr(this_ptr);
31771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31773         this_ptr_conv.is_owned = false;
31774         LDKOutPoint val_conv;
31775         val_conv.inner = untag_ptr(val);
31776         val_conv.is_owned = ptr_is_owned(val);
31777         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31778         val_conv = OutPoint_clone(&val_conv);
31779         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
31780 }
31781
31782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31783         LDKChannelDetails this_ptr_conv;
31784         this_ptr_conv.inner = untag_ptr(this_ptr);
31785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31787         this_ptr_conv.is_owned = false;
31788         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
31789         int64_t ret_ref = 0;
31790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31792         return ret_ref;
31793 }
31794
31795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31796         LDKChannelDetails this_ptr_conv;
31797         this_ptr_conv.inner = untag_ptr(this_ptr);
31798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31800         this_ptr_conv.is_owned = false;
31801         LDKChannelTypeFeatures val_conv;
31802         val_conv.inner = untag_ptr(val);
31803         val_conv.is_owned = ptr_is_owned(val);
31804         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31805         val_conv = ChannelTypeFeatures_clone(&val_conv);
31806         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
31807 }
31808
31809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31810         LDKChannelDetails this_ptr_conv;
31811         this_ptr_conv.inner = untag_ptr(this_ptr);
31812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31814         this_ptr_conv.is_owned = false;
31815         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31816         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
31817         int64_t ret_ref = tag_ptr(ret_copy, true);
31818         return ret_ref;
31819 }
31820
31821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31822         LDKChannelDetails this_ptr_conv;
31823         this_ptr_conv.inner = untag_ptr(this_ptr);
31824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31826         this_ptr_conv.is_owned = false;
31827         void* val_ptr = untag_ptr(val);
31828         CHECK_ACCESS(val_ptr);
31829         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31830         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31831         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
31832 }
31833
31834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31835         LDKChannelDetails this_ptr_conv;
31836         this_ptr_conv.inner = untag_ptr(this_ptr);
31837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31839         this_ptr_conv.is_owned = false;
31840         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31841         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
31842         int64_t ret_ref = tag_ptr(ret_copy, true);
31843         return ret_ref;
31844 }
31845
31846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31847         LDKChannelDetails this_ptr_conv;
31848         this_ptr_conv.inner = untag_ptr(this_ptr);
31849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31851         this_ptr_conv.is_owned = false;
31852         void* val_ptr = untag_ptr(val);
31853         CHECK_ACCESS(val_ptr);
31854         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31855         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31856         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
31857 }
31858
31859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31860         LDKChannelDetails this_ptr_conv;
31861         this_ptr_conv.inner = untag_ptr(this_ptr);
31862         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31864         this_ptr_conv.is_owned = false;
31865         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31866         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
31867         int64_t ret_ref = tag_ptr(ret_copy, true);
31868         return ret_ref;
31869 }
31870
31871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31872         LDKChannelDetails this_ptr_conv;
31873         this_ptr_conv.inner = untag_ptr(this_ptr);
31874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31876         this_ptr_conv.is_owned = false;
31877         void* val_ptr = untag_ptr(val);
31878         CHECK_ACCESS(val_ptr);
31879         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31880         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31881         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
31882 }
31883
31884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31885         LDKChannelDetails this_ptr_conv;
31886         this_ptr_conv.inner = untag_ptr(this_ptr);
31887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31889         this_ptr_conv.is_owned = false;
31890         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
31891         return ret_conv;
31892 }
31893
31894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31895         LDKChannelDetails this_ptr_conv;
31896         this_ptr_conv.inner = untag_ptr(this_ptr);
31897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31899         this_ptr_conv.is_owned = false;
31900         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
31901 }
31902
31903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
31904         LDKChannelDetails this_ptr_conv;
31905         this_ptr_conv.inner = untag_ptr(this_ptr);
31906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31908         this_ptr_conv.is_owned = false;
31909         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31910         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
31911         int64_t ret_ref = tag_ptr(ret_copy, true);
31912         return ret_ref;
31913 }
31914
31915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31916         LDKChannelDetails this_ptr_conv;
31917         this_ptr_conv.inner = untag_ptr(this_ptr);
31918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31920         this_ptr_conv.is_owned = false;
31921         void* val_ptr = untag_ptr(val);
31922         CHECK_ACCESS(val_ptr);
31923         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31924         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31925         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
31926 }
31927
31928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31929         LDKChannelDetails this_ptr_conv;
31930         this_ptr_conv.inner = untag_ptr(this_ptr);
31931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31933         this_ptr_conv.is_owned = false;
31934         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
31935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes);
31936         return ret_arr;
31937 }
31938
31939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31940         LDKChannelDetails this_ptr_conv;
31941         this_ptr_conv.inner = untag_ptr(this_ptr);
31942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31944         this_ptr_conv.is_owned = false;
31945         LDKU128 val_ref;
31946         CHECK((*env)->GetArrayLength(env, val) == 16);
31947         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
31948         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
31949 }
31950
31951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31952         LDKChannelDetails this_ptr_conv;
31953         this_ptr_conv.inner = untag_ptr(this_ptr);
31954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31956         this_ptr_conv.is_owned = false;
31957         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
31958         return ret_conv;
31959 }
31960
31961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31962         LDKChannelDetails this_ptr_conv;
31963         this_ptr_conv.inner = untag_ptr(this_ptr);
31964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31966         this_ptr_conv.is_owned = false;
31967         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
31968 }
31969
31970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31971         LDKChannelDetails this_ptr_conv;
31972         this_ptr_conv.inner = untag_ptr(this_ptr);
31973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31975         this_ptr_conv.is_owned = false;
31976         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
31977         return ret_conv;
31978 }
31979
31980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31981         LDKChannelDetails this_ptr_conv;
31982         this_ptr_conv.inner = untag_ptr(this_ptr);
31983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31985         this_ptr_conv.is_owned = false;
31986         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
31987 }
31988
31989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31990         LDKChannelDetails this_ptr_conv;
31991         this_ptr_conv.inner = untag_ptr(this_ptr);
31992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31994         this_ptr_conv.is_owned = false;
31995         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
31996         return ret_conv;
31997 }
31998
31999 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) {
32000         LDKChannelDetails this_ptr_conv;
32001         this_ptr_conv.inner = untag_ptr(this_ptr);
32002         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32004         this_ptr_conv.is_owned = false;
32005         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
32006 }
32007
32008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32009         LDKChannelDetails this_ptr_conv;
32010         this_ptr_conv.inner = untag_ptr(this_ptr);
32011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32013         this_ptr_conv.is_owned = false;
32014         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
32015         return ret_conv;
32016 }
32017
32018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32019         LDKChannelDetails this_ptr_conv;
32020         this_ptr_conv.inner = untag_ptr(this_ptr);
32021         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32023         this_ptr_conv.is_owned = false;
32024         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
32025 }
32026
32027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
32028         LDKChannelDetails this_ptr_conv;
32029         this_ptr_conv.inner = untag_ptr(this_ptr);
32030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32032         this_ptr_conv.is_owned = false;
32033         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32034         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
32035         int64_t ret_ref = tag_ptr(ret_copy, true);
32036         return ret_ref;
32037 }
32038
32039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32040         LDKChannelDetails this_ptr_conv;
32041         this_ptr_conv.inner = untag_ptr(this_ptr);
32042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32044         this_ptr_conv.is_owned = false;
32045         void* val_ptr = untag_ptr(val);
32046         CHECK_ACCESS(val_ptr);
32047         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32048         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32049         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
32050 }
32051
32052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr) {
32053         LDKChannelDetails this_ptr_conv;
32054         this_ptr_conv.inner = untag_ptr(this_ptr);
32055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32057         this_ptr_conv.is_owned = false;
32058         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32059         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
32060         int64_t ret_ref = tag_ptr(ret_copy, true);
32061         return ret_ref;
32062 }
32063
32064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32065         LDKChannelDetails this_ptr_conv;
32066         this_ptr_conv.inner = untag_ptr(this_ptr);
32067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32069         this_ptr_conv.is_owned = false;
32070         void* val_ptr = untag_ptr(val);
32071         CHECK_ACCESS(val_ptr);
32072         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32073         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32074         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
32075 }
32076
32077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32078         LDKChannelDetails this_ptr_conv;
32079         this_ptr_conv.inner = untag_ptr(this_ptr);
32080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32082         this_ptr_conv.is_owned = false;
32083         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
32084         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
32085         int64_t ret_ref = tag_ptr(ret_copy, true);
32086         return ret_ref;
32087 }
32088
32089 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) {
32090         LDKChannelDetails this_ptr_conv;
32091         this_ptr_conv.inner = untag_ptr(this_ptr);
32092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32094         this_ptr_conv.is_owned = false;
32095         void* val_ptr = untag_ptr(val);
32096         CHECK_ACCESS(val_ptr);
32097         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
32098         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
32099         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
32100 }
32101
32102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
32103         LDKChannelDetails this_ptr_conv;
32104         this_ptr_conv.inner = untag_ptr(this_ptr);
32105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32107         this_ptr_conv.is_owned = false;
32108         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
32109         return ret_conv;
32110 }
32111
32112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32113         LDKChannelDetails this_ptr_conv;
32114         this_ptr_conv.inner = untag_ptr(this_ptr);
32115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32117         this_ptr_conv.is_owned = false;
32118         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
32119 }
32120
32121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
32122         LDKChannelDetails this_ptr_conv;
32123         this_ptr_conv.inner = untag_ptr(this_ptr);
32124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32126         this_ptr_conv.is_owned = false;
32127         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
32128         return ret_conv;
32129 }
32130
32131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32132         LDKChannelDetails this_ptr_conv;
32133         this_ptr_conv.inner = untag_ptr(this_ptr);
32134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32136         this_ptr_conv.is_owned = false;
32137         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
32138 }
32139
32140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
32141         LDKChannelDetails this_ptr_conv;
32142         this_ptr_conv.inner = untag_ptr(this_ptr);
32143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32145         this_ptr_conv.is_owned = false;
32146         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
32147         return ret_conv;
32148 }
32149
32150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32151         LDKChannelDetails this_ptr_conv;
32152         this_ptr_conv.inner = untag_ptr(this_ptr);
32153         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32155         this_ptr_conv.is_owned = false;
32156         ChannelDetails_set_is_usable(&this_ptr_conv, val);
32157 }
32158
32159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
32160         LDKChannelDetails this_ptr_conv;
32161         this_ptr_conv.inner = untag_ptr(this_ptr);
32162         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32164         this_ptr_conv.is_owned = false;
32165         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
32166         return ret_conv;
32167 }
32168
32169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32170         LDKChannelDetails this_ptr_conv;
32171         this_ptr_conv.inner = untag_ptr(this_ptr);
32172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32174         this_ptr_conv.is_owned = false;
32175         ChannelDetails_set_is_public(&this_ptr_conv, val);
32176 }
32177
32178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32179         LDKChannelDetails this_ptr_conv;
32180         this_ptr_conv.inner = untag_ptr(this_ptr);
32181         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32183         this_ptr_conv.is_owned = false;
32184         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32185         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
32186         int64_t ret_ref = tag_ptr(ret_copy, true);
32187         return ret_ref;
32188 }
32189
32190 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) {
32191         LDKChannelDetails this_ptr_conv;
32192         this_ptr_conv.inner = untag_ptr(this_ptr);
32193         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32195         this_ptr_conv.is_owned = false;
32196         void* val_ptr = untag_ptr(val);
32197         CHECK_ACCESS(val_ptr);
32198         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32199         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32200         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32201 }
32202
32203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32204         LDKChannelDetails this_ptr_conv;
32205         this_ptr_conv.inner = untag_ptr(this_ptr);
32206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32208         this_ptr_conv.is_owned = false;
32209         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32210         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
32211         int64_t ret_ref = tag_ptr(ret_copy, true);
32212         return ret_ref;
32213 }
32214
32215 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) {
32216         LDKChannelDetails this_ptr_conv;
32217         this_ptr_conv.inner = untag_ptr(this_ptr);
32218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32220         this_ptr_conv.is_owned = false;
32221         void* val_ptr = untag_ptr(val);
32222         CHECK_ACCESS(val_ptr);
32223         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32224         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32225         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32226 }
32227
32228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32229         LDKChannelDetails this_ptr_conv;
32230         this_ptr_conv.inner = untag_ptr(this_ptr);
32231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32233         this_ptr_conv.is_owned = false;
32234         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
32235         int64_t ret_ref = 0;
32236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32238         return ret_ref;
32239 }
32240
32241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32242         LDKChannelDetails this_ptr_conv;
32243         this_ptr_conv.inner = untag_ptr(this_ptr);
32244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32246         this_ptr_conv.is_owned = false;
32247         LDKChannelConfig val_conv;
32248         val_conv.inner = untag_ptr(val);
32249         val_conv.is_owned = ptr_is_owned(val);
32250         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32251         val_conv = ChannelConfig_clone(&val_conv);
32252         ChannelDetails_set_config(&this_ptr_conv, val_conv);
32253 }
32254
32255 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) {
32256         LDKThirtyTwoBytes channel_id_arg_ref;
32257         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32258         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32259         LDKChannelCounterparty counterparty_arg_conv;
32260         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
32261         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
32262         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
32263         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
32264         LDKOutPoint funding_txo_arg_conv;
32265         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
32266         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
32267         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
32268         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
32269         LDKChannelTypeFeatures channel_type_arg_conv;
32270         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
32271         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
32272         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
32273         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
32274         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
32275         CHECK_ACCESS(short_channel_id_arg_ptr);
32276         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
32277         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
32278         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
32279         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
32280         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
32281         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
32282         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
32283         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
32284         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
32285         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
32286         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
32287         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
32288         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
32289         LDKU128 user_channel_id_arg_ref;
32290         CHECK((*env)->GetArrayLength(env, user_channel_id_arg) == 16);
32291         (*env)->GetByteArrayRegion(env, user_channel_id_arg, 0, 16, user_channel_id_arg_ref.le_bytes);
32292         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
32293         CHECK_ACCESS(confirmations_required_arg_ptr);
32294         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
32295         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
32296         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
32297         CHECK_ACCESS(confirmations_arg_ptr);
32298         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
32299         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
32300         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
32301         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
32302         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
32303         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
32304         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
32305         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
32306         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
32307         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
32308         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
32309         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
32310         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
32311         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
32312         LDKChannelConfig config_arg_conv;
32313         config_arg_conv.inner = untag_ptr(config_arg);
32314         config_arg_conv.is_owned = ptr_is_owned(config_arg);
32315         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
32316         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
32317         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);
32318         int64_t ret_ref = 0;
32319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32321         return ret_ref;
32322 }
32323
32324 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
32325         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
32326         int64_t ret_ref = 0;
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32329         return ret_ref;
32330 }
32331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32332         LDKChannelDetails arg_conv;
32333         arg_conv.inner = untag_ptr(arg);
32334         arg_conv.is_owned = ptr_is_owned(arg);
32335         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32336         arg_conv.is_owned = false;
32337         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
32338         return ret_conv;
32339 }
32340
32341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32342         LDKChannelDetails orig_conv;
32343         orig_conv.inner = untag_ptr(orig);
32344         orig_conv.is_owned = ptr_is_owned(orig);
32345         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32346         orig_conv.is_owned = false;
32347         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
32348         int64_t ret_ref = 0;
32349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32350         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32351         return ret_ref;
32352 }
32353
32354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32355         LDKChannelDetails this_arg_conv;
32356         this_arg_conv.inner = untag_ptr(this_arg);
32357         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32359         this_arg_conv.is_owned = false;
32360         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32361         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
32362         int64_t ret_ref = tag_ptr(ret_copy, true);
32363         return ret_ref;
32364 }
32365
32366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32367         LDKChannelDetails this_arg_conv;
32368         this_arg_conv.inner = untag_ptr(this_arg);
32369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32371         this_arg_conv.is_owned = false;
32372         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32373         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
32374         int64_t ret_ref = tag_ptr(ret_copy, true);
32375         return ret_ref;
32376 }
32377
32378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32379         if (!ptr_is_owned(this_ptr)) return;
32380         void* this_ptr_ptr = untag_ptr(this_ptr);
32381         CHECK_ACCESS(this_ptr_ptr);
32382         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
32383         FREE(untag_ptr(this_ptr));
32384         PaymentSendFailure_free(this_ptr_conv);
32385 }
32386
32387 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
32388         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32389         *ret_copy = PaymentSendFailure_clone(arg);
32390         int64_t ret_ref = tag_ptr(ret_copy, true);
32391         return ret_ref;
32392 }
32393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32394         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
32395         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
32396         return ret_conv;
32397 }
32398
32399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32400         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
32401         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32402         *ret_copy = PaymentSendFailure_clone(orig_conv);
32403         int64_t ret_ref = tag_ptr(ret_copy, true);
32404         return ret_ref;
32405 }
32406
32407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
32408         void* a_ptr = untag_ptr(a);
32409         CHECK_ACCESS(a_ptr);
32410         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
32411         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
32412         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32413         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
32414         int64_t ret_ref = tag_ptr(ret_copy, true);
32415         return ret_ref;
32416 }
32417
32418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
32419         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
32420         a_constr.datalen = (*env)->GetArrayLength(env, a);
32421         if (a_constr.datalen > 0)
32422                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
32423         else
32424                 a_constr.data = NULL;
32425         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
32426         for (size_t w = 0; w < a_constr.datalen; w++) {
32427                 int64_t a_conv_22 = a_vals[w];
32428                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
32429                 CHECK_ACCESS(a_conv_22_ptr);
32430                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
32431                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
32432                 a_constr.data[w] = a_conv_22_conv;
32433         }
32434         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
32435         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32436         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
32437         int64_t ret_ref = tag_ptr(ret_copy, true);
32438         return ret_ref;
32439 }
32440
32441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1resend_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
32442         LDKCVec_APIErrorZ a_constr;
32443         a_constr.datalen = (*env)->GetArrayLength(env, a);
32444         if (a_constr.datalen > 0)
32445                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
32446         else
32447                 a_constr.data = NULL;
32448         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
32449         for (size_t k = 0; k < a_constr.datalen; k++) {
32450                 int64_t a_conv_10 = a_vals[k];
32451                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
32452                 CHECK_ACCESS(a_conv_10_ptr);
32453                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
32454                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
32455                 a_constr.data[k] = a_conv_10_conv;
32456         }
32457         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
32458         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32459         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
32460         int64_t ret_ref = tag_ptr(ret_copy, true);
32461         return ret_ref;
32462 }
32463
32464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
32465         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32466         *ret_copy = PaymentSendFailure_duplicate_payment();
32467         int64_t ret_ref = tag_ptr(ret_copy, true);
32468         return ret_ref;
32469 }
32470
32471 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) {
32472         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
32473         results_constr.datalen = (*env)->GetArrayLength(env, results);
32474         if (results_constr.datalen > 0)
32475                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
32476         else
32477                 results_constr.data = NULL;
32478         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
32479         for (size_t w = 0; w < results_constr.datalen; w++) {
32480                 int64_t results_conv_22 = results_vals[w];
32481                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
32482                 CHECK_ACCESS(results_conv_22_ptr);
32483                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
32484                 results_constr.data[w] = results_conv_22_conv;
32485         }
32486         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
32487         LDKRouteParameters failed_paths_retry_conv;
32488         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
32489         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
32490         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
32491         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
32492         LDKThirtyTwoBytes payment_id_ref;
32493         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32494         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32495         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32496         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
32497         int64_t ret_ref = tag_ptr(ret_copy, true);
32498         return ret_ref;
32499 }
32500
32501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32502         LDKPhantomRouteHints this_obj_conv;
32503         this_obj_conv.inner = untag_ptr(this_obj);
32504         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32506         PhantomRouteHints_free(this_obj_conv);
32507 }
32508
32509 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
32510         LDKPhantomRouteHints this_ptr_conv;
32511         this_ptr_conv.inner = untag_ptr(this_ptr);
32512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32514         this_ptr_conv.is_owned = false;
32515         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
32516         int64_tArray ret_arr = NULL;
32517         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32518         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32519         for (size_t q = 0; q < ret_var.datalen; q++) {
32520                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32521                 int64_t ret_conv_16_ref = 0;
32522                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32523                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32524                 ret_arr_ptr[q] = ret_conv_16_ref;
32525         }
32526         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32527         FREE(ret_var.data);
32528         return ret_arr;
32529 }
32530
32531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32532         LDKPhantomRouteHints this_ptr_conv;
32533         this_ptr_conv.inner = untag_ptr(this_ptr);
32534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32536         this_ptr_conv.is_owned = false;
32537         LDKCVec_ChannelDetailsZ val_constr;
32538         val_constr.datalen = (*env)->GetArrayLength(env, val);
32539         if (val_constr.datalen > 0)
32540                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
32541         else
32542                 val_constr.data = NULL;
32543         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32544         for (size_t q = 0; q < val_constr.datalen; q++) {
32545                 int64_t val_conv_16 = val_vals[q];
32546                 LDKChannelDetails val_conv_16_conv;
32547                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
32548                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
32549                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
32550                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
32551                 val_constr.data[q] = val_conv_16_conv;
32552         }
32553         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32554         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
32555 }
32556
32557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
32558         LDKPhantomRouteHints this_ptr_conv;
32559         this_ptr_conv.inner = untag_ptr(this_ptr);
32560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32562         this_ptr_conv.is_owned = false;
32563         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
32564         return ret_conv;
32565 }
32566
32567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32568         LDKPhantomRouteHints this_ptr_conv;
32569         this_ptr_conv.inner = untag_ptr(this_ptr);
32570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32572         this_ptr_conv.is_owned = false;
32573         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
32574 }
32575
32576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32577         LDKPhantomRouteHints this_ptr_conv;
32578         this_ptr_conv.inner = untag_ptr(this_ptr);
32579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32581         this_ptr_conv.is_owned = false;
32582         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32583         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
32584         return ret_arr;
32585 }
32586
32587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32588         LDKPhantomRouteHints this_ptr_conv;
32589         this_ptr_conv.inner = untag_ptr(this_ptr);
32590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32592         this_ptr_conv.is_owned = false;
32593         LDKPublicKey val_ref;
32594         CHECK((*env)->GetArrayLength(env, val) == 33);
32595         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32596         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
32597 }
32598
32599 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) {
32600         LDKCVec_ChannelDetailsZ channels_arg_constr;
32601         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
32602         if (channels_arg_constr.datalen > 0)
32603                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
32604         else
32605                 channels_arg_constr.data = NULL;
32606         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
32607         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
32608                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
32609                 LDKChannelDetails channels_arg_conv_16_conv;
32610                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
32611                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
32612                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
32613                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
32614                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
32615         }
32616         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
32617         LDKPublicKey real_node_pubkey_arg_ref;
32618         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
32619         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
32620         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
32621         int64_t ret_ref = 0;
32622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32623         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32624         return ret_ref;
32625 }
32626
32627 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
32628         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
32629         int64_t ret_ref = 0;
32630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32632         return ret_ref;
32633 }
32634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32635         LDKPhantomRouteHints arg_conv;
32636         arg_conv.inner = untag_ptr(arg);
32637         arg_conv.is_owned = ptr_is_owned(arg);
32638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32639         arg_conv.is_owned = false;
32640         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
32641         return ret_conv;
32642 }
32643
32644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32645         LDKPhantomRouteHints orig_conv;
32646         orig_conv.inner = untag_ptr(orig);
32647         orig_conv.is_owned = ptr_is_owned(orig);
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32649         orig_conv.is_owned = false;
32650         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
32651         int64_t ret_ref = 0;
32652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32654         return ret_ref;
32655 }
32656
32657 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) {
32658         void* fee_est_ptr = untag_ptr(fee_est);
32659         CHECK_ACCESS(fee_est_ptr);
32660         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
32661         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
32662                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32663                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
32664         }
32665         void* chain_monitor_ptr = untag_ptr(chain_monitor);
32666         CHECK_ACCESS(chain_monitor_ptr);
32667         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
32668         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
32669                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32670                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
32671         }
32672         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
32673         CHECK_ACCESS(tx_broadcaster_ptr);
32674         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
32675         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
32676                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32677                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
32678         }
32679         void* logger_ptr = untag_ptr(logger);
32680         CHECK_ACCESS(logger_ptr);
32681         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32682         if (logger_conv.free == LDKLogger_JCalls_free) {
32683                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32684                 LDKLogger_JCalls_cloned(&logger_conv);
32685         }
32686         void* keys_manager_ptr = untag_ptr(keys_manager);
32687         CHECK_ACCESS(keys_manager_ptr);
32688         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
32689         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
32690                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32691                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
32692         }
32693         LDKUserConfig config_conv;
32694         config_conv.inner = untag_ptr(config);
32695         config_conv.is_owned = ptr_is_owned(config);
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
32697         config_conv = UserConfig_clone(&config_conv);
32698         LDKChainParameters params_conv;
32699         params_conv.inner = untag_ptr(params);
32700         params_conv.is_owned = ptr_is_owned(params);
32701         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
32702         params_conv = ChainParameters_clone(&params_conv);
32703         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
32704         int64_t ret_ref = 0;
32705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32707         return ret_ref;
32708 }
32709
32710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
32711         LDKChannelManager this_arg_conv;
32712         this_arg_conv.inner = untag_ptr(this_arg);
32713         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32715         this_arg_conv.is_owned = false;
32716         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
32717         int64_t ret_ref = 0;
32718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32720         return ret_ref;
32721 }
32722
32723 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) {
32724         LDKChannelManager this_arg_conv;
32725         this_arg_conv.inner = untag_ptr(this_arg);
32726         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32728         this_arg_conv.is_owned = false;
32729         LDKPublicKey their_network_key_ref;
32730         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
32731         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
32732         LDKU128 user_channel_id_ref;
32733         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
32734         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
32735         LDKUserConfig override_config_conv;
32736         override_config_conv.inner = untag_ptr(override_config);
32737         override_config_conv.is_owned = ptr_is_owned(override_config);
32738         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
32739         override_config_conv = UserConfig_clone(&override_config_conv);
32740         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
32741         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
32742         return tag_ptr(ret_conv, true);
32743 }
32744
32745 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
32746         LDKChannelManager this_arg_conv;
32747         this_arg_conv.inner = untag_ptr(this_arg);
32748         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32750         this_arg_conv.is_owned = false;
32751         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
32752         int64_tArray ret_arr = NULL;
32753         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32754         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32755         for (size_t q = 0; q < ret_var.datalen; q++) {
32756                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32757                 int64_t ret_conv_16_ref = 0;
32758                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32759                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32760                 ret_arr_ptr[q] = ret_conv_16_ref;
32761         }
32762         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32763         FREE(ret_var.data);
32764         return ret_arr;
32765 }
32766
32767 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
32768         LDKChannelManager this_arg_conv;
32769         this_arg_conv.inner = untag_ptr(this_arg);
32770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32772         this_arg_conv.is_owned = false;
32773         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
32774         int64_tArray ret_arr = NULL;
32775         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32776         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32777         for (size_t q = 0; q < ret_var.datalen; q++) {
32778                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32779                 int64_t ret_conv_16_ref = 0;
32780                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32781                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32782                 ret_arr_ptr[q] = ret_conv_16_ref;
32783         }
32784         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32785         FREE(ret_var.data);
32786         return ret_arr;
32787 }
32788
32789 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) {
32790         LDKChannelManager this_arg_conv;
32791         this_arg_conv.inner = untag_ptr(this_arg);
32792         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32794         this_arg_conv.is_owned = false;
32795         unsigned char channel_id_arr[32];
32796         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32797         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32798         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32799         LDKPublicKey counterparty_node_id_ref;
32800         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32801         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32802         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32803         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
32804         return tag_ptr(ret_conv, true);
32805 }
32806
32807 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) {
32808         LDKChannelManager this_arg_conv;
32809         this_arg_conv.inner = untag_ptr(this_arg);
32810         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32812         this_arg_conv.is_owned = false;
32813         unsigned char channel_id_arr[32];
32814         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32815         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32816         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32817         LDKPublicKey counterparty_node_id_ref;
32818         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32819         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32820         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32821         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
32822         return tag_ptr(ret_conv, true);
32823 }
32824
32825 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) {
32826         LDKChannelManager this_arg_conv;
32827         this_arg_conv.inner = untag_ptr(this_arg);
32828         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32830         this_arg_conv.is_owned = false;
32831         unsigned char channel_id_arr[32];
32832         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32833         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32834         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32835         LDKPublicKey counterparty_node_id_ref;
32836         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32837         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32838         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32839         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
32840         return tag_ptr(ret_conv, true);
32841 }
32842
32843 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) {
32844         LDKChannelManager this_arg_conv;
32845         this_arg_conv.inner = untag_ptr(this_arg);
32846         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32848         this_arg_conv.is_owned = false;
32849         unsigned char channel_id_arr[32];
32850         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32851         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32852         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32853         LDKPublicKey counterparty_node_id_ref;
32854         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32855         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32856         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32857         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
32858         return tag_ptr(ret_conv, true);
32859 }
32860
32861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
32862         LDKChannelManager this_arg_conv;
32863         this_arg_conv.inner = untag_ptr(this_arg);
32864         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32866         this_arg_conv.is_owned = false;
32867         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
32868 }
32869
32870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
32871         LDKChannelManager this_arg_conv;
32872         this_arg_conv.inner = untag_ptr(this_arg);
32873         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32875         this_arg_conv.is_owned = false;
32876         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
32877 }
32878
32879 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) {
32880         LDKChannelManager this_arg_conv;
32881         this_arg_conv.inner = untag_ptr(this_arg);
32882         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32884         this_arg_conv.is_owned = false;
32885         LDKRoute route_conv;
32886         route_conv.inner = untag_ptr(route);
32887         route_conv.is_owned = ptr_is_owned(route);
32888         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
32889         route_conv.is_owned = false;
32890         LDKThirtyTwoBytes payment_hash_ref;
32891         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32892         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32893         LDKThirtyTwoBytes payment_secret_ref;
32894         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
32895         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
32896         LDKThirtyTwoBytes payment_id_ref;
32897         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32898         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32899         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
32900         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref, payment_id_ref);
32901         return tag_ptr(ret_conv, true);
32902 }
32903
32904 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) {
32905         LDKChannelManager this_arg_conv;
32906         this_arg_conv.inner = untag_ptr(this_arg);
32907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32909         this_arg_conv.is_owned = false;
32910         LDKRoute route_conv;
32911         route_conv.inner = untag_ptr(route);
32912         route_conv.is_owned = ptr_is_owned(route);
32913         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
32914         route_conv.is_owned = false;
32915         LDKThirtyTwoBytes payment_id_ref;
32916         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32917         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32918         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
32919         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
32920         return tag_ptr(ret_conv, true);
32921 }
32922
32923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
32924         LDKChannelManager this_arg_conv;
32925         this_arg_conv.inner = untag_ptr(this_arg);
32926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32928         this_arg_conv.is_owned = false;
32929         LDKThirtyTwoBytes payment_id_ref;
32930         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32931         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32932         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
32933 }
32934
32935 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) {
32936         LDKChannelManager this_arg_conv;
32937         this_arg_conv.inner = untag_ptr(this_arg);
32938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32940         this_arg_conv.is_owned = false;
32941         LDKRoute route_conv;
32942         route_conv.inner = untag_ptr(route);
32943         route_conv.is_owned = ptr_is_owned(route);
32944         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
32945         route_conv.is_owned = false;
32946         LDKThirtyTwoBytes payment_preimage_ref;
32947         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
32948         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
32949         LDKThirtyTwoBytes payment_id_ref;
32950         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32951         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32952         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
32953         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref, payment_id_ref);
32954         return tag_ptr(ret_conv, true);
32955 }
32956
32957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
32958         LDKChannelManager this_arg_conv;
32959         this_arg_conv.inner = untag_ptr(this_arg);
32960         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32962         this_arg_conv.is_owned = false;
32963         LDKCVec_RouteHopZ hops_constr;
32964         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
32965         if (hops_constr.datalen > 0)
32966                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
32967         else
32968                 hops_constr.data = NULL;
32969         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
32970         for (size_t k = 0; k < hops_constr.datalen; k++) {
32971                 int64_t hops_conv_10 = hops_vals[k];
32972                 LDKRouteHop hops_conv_10_conv;
32973                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
32974                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
32975                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
32976                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
32977                 hops_constr.data[k] = hops_conv_10_conv;
32978         }
32979         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
32980         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
32981         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
32982         return tag_ptr(ret_conv, true);
32983 }
32984
32985 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) {
32986         LDKChannelManager this_arg_conv;
32987         this_arg_conv.inner = untag_ptr(this_arg);
32988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32990         this_arg_conv.is_owned = false;
32991         unsigned char temporary_channel_id_arr[32];
32992         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
32993         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
32994         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
32995         LDKPublicKey counterparty_node_id_ref;
32996         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32997         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32998         LDKTransaction funding_transaction_ref;
32999         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
33000         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
33001         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
33002         funding_transaction_ref.data_is_owned = true;
33003         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33004         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
33005         return tag_ptr(ret_conv, true);
33006 }
33007
33008 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) {
33009         LDKChannelManager this_arg_conv;
33010         this_arg_conv.inner = untag_ptr(this_arg);
33011         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33013         this_arg_conv.is_owned = false;
33014         LDKPublicKey counterparty_node_id_ref;
33015         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33016         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33017         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
33018         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
33019         if (channel_ids_constr.datalen > 0)
33020                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
33021         else
33022                 channel_ids_constr.data = NULL;
33023         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
33024                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
33025                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
33026                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
33027                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
33028                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
33029         }
33030         LDKChannelConfig config_conv;
33031         config_conv.inner = untag_ptr(config);
33032         config_conv.is_owned = ptr_is_owned(config);
33033         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33034         config_conv.is_owned = false;
33035         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33036         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
33037         return tag_ptr(ret_conv, true);
33038 }
33039
33040 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) {
33041         LDKChannelManager this_arg_conv;
33042         this_arg_conv.inner = untag_ptr(this_arg);
33043         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33045         this_arg_conv.is_owned = false;
33046         LDKThirtyTwoBytes intercept_id_ref;
33047         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33048         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33049         unsigned char next_hop_channel_id_arr[32];
33050         CHECK((*env)->GetArrayLength(env, next_hop_channel_id) == 32);
33051         (*env)->GetByteArrayRegion(env, next_hop_channel_id, 0, 32, next_hop_channel_id_arr);
33052         unsigned char (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
33053         LDKPublicKey _next_node_id_ref;
33054         CHECK((*env)->GetArrayLength(env, _next_node_id) == 33);
33055         (*env)->GetByteArrayRegion(env, _next_node_id, 0, 33, _next_node_id_ref.compressed_form);
33056         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33057         *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);
33058         return tag_ptr(ret_conv, true);
33059 }
33060
33061 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) {
33062         LDKChannelManager this_arg_conv;
33063         this_arg_conv.inner = untag_ptr(this_arg);
33064         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33066         this_arg_conv.is_owned = false;
33067         LDKThirtyTwoBytes intercept_id_ref;
33068         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33069         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33070         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33071         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
33072         return tag_ptr(ret_conv, true);
33073 }
33074
33075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
33076         LDKChannelManager this_arg_conv;
33077         this_arg_conv.inner = untag_ptr(this_arg);
33078         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33080         this_arg_conv.is_owned = false;
33081         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
33082 }
33083
33084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
33085         LDKChannelManager this_arg_conv;
33086         this_arg_conv.inner = untag_ptr(this_arg);
33087         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33089         this_arg_conv.is_owned = false;
33090         ChannelManager_timer_tick_occurred(&this_arg_conv);
33091 }
33092
33093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33094         LDKChannelManager this_arg_conv;
33095         this_arg_conv.inner = untag_ptr(this_arg);
33096         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33098         this_arg_conv.is_owned = false;
33099         unsigned char payment_hash_arr[32];
33100         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33101         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33102         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
33103         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
33104 }
33105
33106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
33107         LDKChannelManager this_arg_conv;
33108         this_arg_conv.inner = untag_ptr(this_arg);
33109         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33111         this_arg_conv.is_owned = false;
33112         LDKThirtyTwoBytes payment_preimage_ref;
33113         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33114         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33115         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
33116 }
33117
33118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
33119         LDKChannelManager this_arg_conv;
33120         this_arg_conv.inner = untag_ptr(this_arg);
33121         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33123         this_arg_conv.is_owned = false;
33124         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
33126         return ret_arr;
33127 }
33128
33129 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) {
33130         LDKChannelManager this_arg_conv;
33131         this_arg_conv.inner = untag_ptr(this_arg);
33132         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33134         this_arg_conv.is_owned = false;
33135         unsigned char temporary_channel_id_arr[32];
33136         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33137         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33138         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33139         LDKPublicKey counterparty_node_id_ref;
33140         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33141         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33142         LDKU128 user_channel_id_ref;
33143         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33144         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33145         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33146         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33147         return tag_ptr(ret_conv, true);
33148 }
33149
33150 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) {
33151         LDKChannelManager this_arg_conv;
33152         this_arg_conv.inner = untag_ptr(this_arg);
33153         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33155         this_arg_conv.is_owned = false;
33156         unsigned char temporary_channel_id_arr[32];
33157         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33158         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33159         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33160         LDKPublicKey counterparty_node_id_ref;
33161         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33162         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33163         LDKU128 user_channel_id_ref;
33164         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33165         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33166         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33167         *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);
33168         return tag_ptr(ret_conv, true);
33169 }
33170
33171 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) {
33172         LDKChannelManager this_arg_conv;
33173         this_arg_conv.inner = untag_ptr(this_arg);
33174         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33176         this_arg_conv.is_owned = false;
33177         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33178         CHECK_ACCESS(min_value_msat_ptr);
33179         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33180         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33181         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33182         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33183         return tag_ptr(ret_conv, true);
33184 }
33185
33186 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) {
33187         LDKChannelManager this_arg_conv;
33188         this_arg_conv.inner = untag_ptr(this_arg);
33189         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33191         this_arg_conv.is_owned = false;
33192         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33193         CHECK_ACCESS(min_value_msat_ptr);
33194         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33195         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33196         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
33197         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33198         return tag_ptr(ret_conv, true);
33199 }
33200
33201 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) {
33202         LDKChannelManager this_arg_conv;
33203         this_arg_conv.inner = untag_ptr(this_arg);
33204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33206         this_arg_conv.is_owned = false;
33207         LDKThirtyTwoBytes payment_hash_ref;
33208         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33209         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33210         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33211         CHECK_ACCESS(min_value_msat_ptr);
33212         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33213         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33214         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33215         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33216         return tag_ptr(ret_conv, true);
33217 }
33218
33219 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) {
33220         LDKChannelManager this_arg_conv;
33221         this_arg_conv.inner = untag_ptr(this_arg);
33222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33224         this_arg_conv.is_owned = false;
33225         LDKThirtyTwoBytes payment_hash_ref;
33226         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33227         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33228         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33229         CHECK_ACCESS(min_value_msat_ptr);
33230         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33231         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33232         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
33233         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33234         return tag_ptr(ret_conv, true);
33235 }
33236
33237 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) {
33238         LDKChannelManager this_arg_conv;
33239         this_arg_conv.inner = untag_ptr(this_arg);
33240         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33242         this_arg_conv.is_owned = false;
33243         LDKThirtyTwoBytes payment_hash_ref;
33244         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33245         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33246         LDKThirtyTwoBytes payment_secret_ref;
33247         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33248         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33249         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
33250         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
33251         return tag_ptr(ret_conv, true);
33252 }
33253
33254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33255         LDKChannelManager this_arg_conv;
33256         this_arg_conv.inner = untag_ptr(this_arg);
33257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33259         this_arg_conv.is_owned = false;
33260         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
33261         return ret_conv;
33262 }
33263
33264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33265         LDKChannelManager this_arg_conv;
33266         this_arg_conv.inner = untag_ptr(this_arg);
33267         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33269         this_arg_conv.is_owned = false;
33270         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
33271         int64_t ret_ref = 0;
33272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33273         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33274         return ret_ref;
33275 }
33276
33277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1intercept_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33278         LDKChannelManager this_arg_conv;
33279         this_arg_conv.inner = untag_ptr(this_arg);
33280         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33282         this_arg_conv.is_owned = false;
33283         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
33284         return ret_conv;
33285 }
33286
33287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1compute_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
33288         LDKChannelManager this_arg_conv;
33289         this_arg_conv.inner = untag_ptr(this_arg);
33290         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33292         this_arg_conv.is_owned = false;
33293         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
33294         int64_t ret_ref = 0;
33295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33297         return ret_ref;
33298 }
33299
33300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33301         LDKChannelManager this_arg_conv;
33302         this_arg_conv.inner = untag_ptr(this_arg);
33303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33305         this_arg_conv.is_owned = false;
33306         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33307         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
33308         return tag_ptr(ret_ret, true);
33309 }
33310
33311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33312         LDKChannelManager this_arg_conv;
33313         this_arg_conv.inner = untag_ptr(this_arg);
33314         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33316         this_arg_conv.is_owned = false;
33317         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
33318         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
33319         return tag_ptr(ret_ret, true);
33320 }
33321
33322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
33323         LDKChannelManager this_arg_conv;
33324         this_arg_conv.inner = untag_ptr(this_arg);
33325         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33327         this_arg_conv.is_owned = false;
33328         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
33329         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
33330         return tag_ptr(ret_ret, true);
33331 }
33332
33333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
33334         LDKChannelManager this_arg_conv;
33335         this_arg_conv.inner = untag_ptr(this_arg);
33336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33338         this_arg_conv.is_owned = false;
33339         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
33340         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
33341         return tag_ptr(ret_ret, true);
33342 }
33343
33344 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) {
33345         LDKChannelManager this_arg_conv;
33346         this_arg_conv.inner = untag_ptr(this_arg);
33347         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33349         this_arg_conv.is_owned = false;
33350         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
33351         return ret_conv;
33352 }
33353
33354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
33355         LDKChannelManager this_arg_conv;
33356         this_arg_conv.inner = untag_ptr(this_arg);
33357         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33359         this_arg_conv.is_owned = false;
33360         ChannelManager_await_persistable_update(&this_arg_conv);
33361 }
33362
33363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
33364         LDKChannelManager this_arg_conv;
33365         this_arg_conv.inner = untag_ptr(this_arg);
33366         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33368         this_arg_conv.is_owned = false;
33369         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
33370         int64_t ret_ref = 0;
33371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33372         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33373         return ret_ref;
33374 }
33375
33376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
33377         LDKChannelManager this_arg_conv;
33378         this_arg_conv.inner = untag_ptr(this_arg);
33379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33381         this_arg_conv.is_owned = false;
33382         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
33383         int64_t ret_ref = 0;
33384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33386         return ret_ref;
33387 }
33388
33389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
33390         LDKChannelManager this_arg_conv;
33391         this_arg_conv.inner = untag_ptr(this_arg);
33392         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33394         this_arg_conv.is_owned = false;
33395         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
33396         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
33397         return tag_ptr(ret_ret, true);
33398 }
33399
33400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1node_1features(JNIEnv *env, jclass clz) {
33401         LDKNodeFeatures ret_var = provided_node_features();
33402         int64_t ret_ref = 0;
33403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33405         return ret_ref;
33406 }
33407
33408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1channel_1features(JNIEnv *env, jclass clz) {
33409         LDKChannelFeatures ret_var = provided_channel_features();
33410         int64_t ret_ref = 0;
33411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33412         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33413         return ret_ref;
33414 }
33415
33416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz) {
33417         LDKInitFeatures ret_var = provided_init_features();
33418         int64_t ret_ref = 0;
33419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33420         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33421         return ret_ref;
33422 }
33423
33424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
33425         LDKCounterpartyForwardingInfo obj_conv;
33426         obj_conv.inner = untag_ptr(obj);
33427         obj_conv.is_owned = ptr_is_owned(obj);
33428         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33429         obj_conv.is_owned = false;
33430         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
33431         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33432         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33433         CVec_u8Z_free(ret_var);
33434         return ret_arr;
33435 }
33436
33437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33438         LDKu8slice ser_ref;
33439         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33440         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33441         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
33442         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
33443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33444         return tag_ptr(ret_conv, true);
33445 }
33446
33447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
33448         LDKChannelCounterparty obj_conv;
33449         obj_conv.inner = untag_ptr(obj);
33450         obj_conv.is_owned = ptr_is_owned(obj);
33451         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33452         obj_conv.is_owned = false;
33453         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
33454         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33455         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33456         CVec_u8Z_free(ret_var);
33457         return ret_arr;
33458 }
33459
33460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33461         LDKu8slice ser_ref;
33462         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33463         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33464         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
33465         *ret_conv = ChannelCounterparty_read(ser_ref);
33466         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33467         return tag_ptr(ret_conv, true);
33468 }
33469
33470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
33471         LDKChannelDetails obj_conv;
33472         obj_conv.inner = untag_ptr(obj);
33473         obj_conv.is_owned = ptr_is_owned(obj);
33474         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33475         obj_conv.is_owned = false;
33476         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
33477         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33478         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33479         CVec_u8Z_free(ret_var);
33480         return ret_arr;
33481 }
33482
33483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33484         LDKu8slice ser_ref;
33485         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33486         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33487         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
33488         *ret_conv = ChannelDetails_read(ser_ref);
33489         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33490         return tag_ptr(ret_conv, true);
33491 }
33492
33493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
33494         LDKPhantomRouteHints obj_conv;
33495         obj_conv.inner = untag_ptr(obj);
33496         obj_conv.is_owned = ptr_is_owned(obj);
33497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33498         obj_conv.is_owned = false;
33499         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
33500         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33501         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33502         CVec_u8Z_free(ret_var);
33503         return ret_arr;
33504 }
33505
33506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33507         LDKu8slice ser_ref;
33508         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33509         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33510         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
33511         *ret_conv = PhantomRouteHints_read(ser_ref);
33512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33513         return tag_ptr(ret_conv, true);
33514 }
33515
33516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
33517         LDKChannelManager obj_conv;
33518         obj_conv.inner = untag_ptr(obj);
33519         obj_conv.is_owned = ptr_is_owned(obj);
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33521         obj_conv.is_owned = false;
33522         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
33523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33525         CVec_u8Z_free(ret_var);
33526         return ret_arr;
33527 }
33528
33529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33530         LDKChannelManagerReadArgs this_obj_conv;
33531         this_obj_conv.inner = untag_ptr(this_obj);
33532         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33534         ChannelManagerReadArgs_free(this_obj_conv);
33535 }
33536
33537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
33538         LDKChannelManagerReadArgs this_ptr_conv;
33539         this_ptr_conv.inner = untag_ptr(this_ptr);
33540         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33542         this_ptr_conv.is_owned = false;
33543         // WARNING: This object doesn't live past this scope, needs clone!
33544         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv), false);
33545         return ret_ret;
33546 }
33547
33548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33549         LDKChannelManagerReadArgs this_ptr_conv;
33550         this_ptr_conv.inner = untag_ptr(this_ptr);
33551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33553         this_ptr_conv.is_owned = false;
33554         void* val_ptr = untag_ptr(val);
33555         CHECK_ACCESS(val_ptr);
33556         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
33557         if (val_conv.free == LDKKeysInterface_JCalls_free) {
33558                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33559                 LDKKeysInterface_JCalls_cloned(&val_conv);
33560         }
33561         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
33562 }
33563
33564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
33565         LDKChannelManagerReadArgs this_ptr_conv;
33566         this_ptr_conv.inner = untag_ptr(this_ptr);
33567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33569         this_ptr_conv.is_owned = false;
33570         // WARNING: This object doesn't live past this scope, needs clone!
33571         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
33572         return ret_ret;
33573 }
33574
33575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33576         LDKChannelManagerReadArgs this_ptr_conv;
33577         this_ptr_conv.inner = untag_ptr(this_ptr);
33578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33580         this_ptr_conv.is_owned = false;
33581         void* val_ptr = untag_ptr(val);
33582         CHECK_ACCESS(val_ptr);
33583         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
33584         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
33585                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33586                 LDKFeeEstimator_JCalls_cloned(&val_conv);
33587         }
33588         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
33589 }
33590
33591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
33592         LDKChannelManagerReadArgs this_ptr_conv;
33593         this_ptr_conv.inner = untag_ptr(this_ptr);
33594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33596         this_ptr_conv.is_owned = false;
33597         // WARNING: This object doesn't live past this scope, needs clone!
33598         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
33599         return ret_ret;
33600 }
33601
33602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33603         LDKChannelManagerReadArgs this_ptr_conv;
33604         this_ptr_conv.inner = untag_ptr(this_ptr);
33605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33607         this_ptr_conv.is_owned = false;
33608         void* val_ptr = untag_ptr(val);
33609         CHECK_ACCESS(val_ptr);
33610         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
33611         if (val_conv.free == LDKWatch_JCalls_free) {
33612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33613                 LDKWatch_JCalls_cloned(&val_conv);
33614         }
33615         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
33616 }
33617
33618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
33619         LDKChannelManagerReadArgs this_ptr_conv;
33620         this_ptr_conv.inner = untag_ptr(this_ptr);
33621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33623         this_ptr_conv.is_owned = false;
33624         // WARNING: This object doesn't live past this scope, needs clone!
33625         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
33626         return ret_ret;
33627 }
33628
33629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33630         LDKChannelManagerReadArgs this_ptr_conv;
33631         this_ptr_conv.inner = untag_ptr(this_ptr);
33632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33634         this_ptr_conv.is_owned = false;
33635         void* val_ptr = untag_ptr(val);
33636         CHECK_ACCESS(val_ptr);
33637         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
33638         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
33639                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33640                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
33641         }
33642         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
33643 }
33644
33645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
33646         LDKChannelManagerReadArgs this_ptr_conv;
33647         this_ptr_conv.inner = untag_ptr(this_ptr);
33648         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33650         this_ptr_conv.is_owned = false;
33651         // WARNING: This object doesn't live past this scope, needs clone!
33652         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
33653         return ret_ret;
33654 }
33655
33656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33657         LDKChannelManagerReadArgs this_ptr_conv;
33658         this_ptr_conv.inner = untag_ptr(this_ptr);
33659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33661         this_ptr_conv.is_owned = false;
33662         void* val_ptr = untag_ptr(val);
33663         CHECK_ACCESS(val_ptr);
33664         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
33665         if (val_conv.free == LDKLogger_JCalls_free) {
33666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33667                 LDKLogger_JCalls_cloned(&val_conv);
33668         }
33669         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
33670 }
33671
33672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
33673         LDKChannelManagerReadArgs this_ptr_conv;
33674         this_ptr_conv.inner = untag_ptr(this_ptr);
33675         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33677         this_ptr_conv.is_owned = false;
33678         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
33679         int64_t ret_ref = 0;
33680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33682         return ret_ref;
33683 }
33684
33685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33686         LDKChannelManagerReadArgs this_ptr_conv;
33687         this_ptr_conv.inner = untag_ptr(this_ptr);
33688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33690         this_ptr_conv.is_owned = false;
33691         LDKUserConfig val_conv;
33692         val_conv.inner = untag_ptr(val);
33693         val_conv.is_owned = ptr_is_owned(val);
33694         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33695         val_conv = UserConfig_clone(&val_conv);
33696         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
33697 }
33698
33699 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) {
33700         void* keys_manager_ptr = untag_ptr(keys_manager);
33701         CHECK_ACCESS(keys_manager_ptr);
33702         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
33703         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
33704                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33705                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
33706         }
33707         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33708         CHECK_ACCESS(fee_estimator_ptr);
33709         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33710         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33712                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33713         }
33714         void* chain_monitor_ptr = untag_ptr(chain_monitor);
33715         CHECK_ACCESS(chain_monitor_ptr);
33716         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
33717         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
33718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33719                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
33720         }
33721         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
33722         CHECK_ACCESS(tx_broadcaster_ptr);
33723         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
33724         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33725                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33726                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
33727         }
33728         void* logger_ptr = untag_ptr(logger);
33729         CHECK_ACCESS(logger_ptr);
33730         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33731         if (logger_conv.free == LDKLogger_JCalls_free) {
33732                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33733                 LDKLogger_JCalls_cloned(&logger_conv);
33734         }
33735         LDKUserConfig default_config_conv;
33736         default_config_conv.inner = untag_ptr(default_config);
33737         default_config_conv.is_owned = ptr_is_owned(default_config);
33738         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
33739         default_config_conv = UserConfig_clone(&default_config_conv);
33740         LDKCVec_ChannelMonitorZ channel_monitors_constr;
33741         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
33742         if (channel_monitors_constr.datalen > 0)
33743                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
33744         else
33745                 channel_monitors_constr.data = NULL;
33746         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
33747         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
33748                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
33749                 LDKChannelMonitor channel_monitors_conv_16_conv;
33750                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
33751                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
33752                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
33753                 channel_monitors_conv_16_conv.is_owned = false;
33754                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
33755         }
33756         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
33757         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);
33758         int64_t ret_ref = 0;
33759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33760         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33761         return ret_ref;
33762 }
33763
33764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
33765         LDKu8slice ser_ref;
33766         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33767         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33768         LDKChannelManagerReadArgs arg_conv;
33769         arg_conv.inner = untag_ptr(arg);
33770         arg_conv.is_owned = ptr_is_owned(arg);
33771         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33772         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
33773         
33774         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
33775         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
33776         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33777         return tag_ptr(ret_conv, true);
33778 }
33779
33780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33781         LDKExpandedKey this_obj_conv;
33782         this_obj_conv.inner = untag_ptr(this_obj);
33783         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33785         ExpandedKey_free(this_obj_conv);
33786 }
33787
33788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
33789         unsigned char key_material_arr[32];
33790         CHECK((*env)->GetArrayLength(env, key_material) == 32);
33791         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
33792         unsigned char (*key_material_ref)[32] = &key_material_arr;
33793         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
33794         int64_t ret_ref = 0;
33795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33797         return ret_ref;
33798 }
33799
33800 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) {
33801         LDKExpandedKey keys_conv;
33802         keys_conv.inner = untag_ptr(keys);
33803         keys_conv.is_owned = ptr_is_owned(keys);
33804         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33805         keys_conv.is_owned = false;
33806         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33807         CHECK_ACCESS(min_value_msat_ptr);
33808         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33809         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33810         void* keys_manager_ptr = untag_ptr(keys_manager);
33811         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
33812         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
33813         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33814         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
33815         return tag_ptr(ret_conv, true);
33816 }
33817
33818 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) {
33819         LDKExpandedKey keys_conv;
33820         keys_conv.inner = untag_ptr(keys);
33821         keys_conv.is_owned = ptr_is_owned(keys);
33822         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33823         keys_conv.is_owned = false;
33824         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33825         CHECK_ACCESS(min_value_msat_ptr);
33826         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33827         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33828         LDKThirtyTwoBytes payment_hash_ref;
33829         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33830         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33831         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33832         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
33833         return tag_ptr(ret_conv, true);
33834 }
33835
33836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33837         if (!ptr_is_owned(this_ptr)) return;
33838         void* this_ptr_ptr = untag_ptr(this_ptr);
33839         CHECK_ACCESS(this_ptr_ptr);
33840         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
33841         FREE(untag_ptr(this_ptr));
33842         DecodeError_free(this_ptr_conv);
33843 }
33844
33845 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
33846         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33847         *ret_copy = DecodeError_clone(arg);
33848         int64_t ret_ref = tag_ptr(ret_copy, true);
33849         return ret_ref;
33850 }
33851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33852         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
33853         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
33854         return ret_conv;
33855 }
33856
33857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33858         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
33859         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33860         *ret_copy = DecodeError_clone(orig_conv);
33861         int64_t ret_ref = tag_ptr(ret_copy, true);
33862         return ret_ref;
33863 }
33864
33865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
33866         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33867         *ret_copy = DecodeError_unknown_version();
33868         int64_t ret_ref = tag_ptr(ret_copy, true);
33869         return ret_ref;
33870 }
33871
33872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
33873         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33874         *ret_copy = DecodeError_unknown_required_feature();
33875         int64_t ret_ref = tag_ptr(ret_copy, true);
33876         return ret_ref;
33877 }
33878
33879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
33880         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33881         *ret_copy = DecodeError_invalid_value();
33882         int64_t ret_ref = tag_ptr(ret_copy, true);
33883         return ret_ref;
33884 }
33885
33886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
33887         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33888         *ret_copy = DecodeError_short_read();
33889         int64_t ret_ref = tag_ptr(ret_copy, true);
33890         return ret_ref;
33891 }
33892
33893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
33894         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33895         *ret_copy = DecodeError_bad_length_descriptor();
33896         int64_t ret_ref = tag_ptr(ret_copy, true);
33897         return ret_ref;
33898 }
33899
33900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
33901         LDKIOError a_conv = LDKIOError_from_java(env, a);
33902         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33903         *ret_copy = DecodeError_io(a_conv);
33904         int64_t ret_ref = tag_ptr(ret_copy, true);
33905         return ret_ref;
33906 }
33907
33908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
33909         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33910         *ret_copy = DecodeError_unsupported_compression();
33911         int64_t ret_ref = tag_ptr(ret_copy, true);
33912         return ret_ref;
33913 }
33914
33915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33916         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
33917         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
33918         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
33919         return ret_conv;
33920 }
33921
33922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33923         LDKInit this_obj_conv;
33924         this_obj_conv.inner = untag_ptr(this_obj);
33925         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33927         Init_free(this_obj_conv);
33928 }
33929
33930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33931         LDKInit this_ptr_conv;
33932         this_ptr_conv.inner = untag_ptr(this_ptr);
33933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33935         this_ptr_conv.is_owned = false;
33936         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
33937         int64_t ret_ref = 0;
33938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33940         return ret_ref;
33941 }
33942
33943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33944         LDKInit this_ptr_conv;
33945         this_ptr_conv.inner = untag_ptr(this_ptr);
33946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33948         this_ptr_conv.is_owned = false;
33949         LDKInitFeatures val_conv;
33950         val_conv.inner = untag_ptr(val);
33951         val_conv.is_owned = ptr_is_owned(val);
33952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33953         val_conv = InitFeatures_clone(&val_conv);
33954         Init_set_features(&this_ptr_conv, val_conv);
33955 }
33956
33957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
33958         LDKInit this_ptr_conv;
33959         this_ptr_conv.inner = untag_ptr(this_ptr);
33960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33962         this_ptr_conv.is_owned = false;
33963         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
33964         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
33965         int64_t ret_ref = tag_ptr(ret_copy, true);
33966         return ret_ref;
33967 }
33968
33969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33970         LDKInit this_ptr_conv;
33971         this_ptr_conv.inner = untag_ptr(this_ptr);
33972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33974         this_ptr_conv.is_owned = false;
33975         void* val_ptr = untag_ptr(val);
33976         CHECK_ACCESS(val_ptr);
33977         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
33978         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
33979         Init_set_remote_network_address(&this_ptr_conv, val_conv);
33980 }
33981
33982 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) {
33983         LDKInitFeatures features_arg_conv;
33984         features_arg_conv.inner = untag_ptr(features_arg);
33985         features_arg_conv.is_owned = ptr_is_owned(features_arg);
33986         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
33987         features_arg_conv = InitFeatures_clone(&features_arg_conv);
33988         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
33989         CHECK_ACCESS(remote_network_address_arg_ptr);
33990         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
33991         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
33992         int64_t ret_ref = 0;
33993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33995         return ret_ref;
33996 }
33997
33998 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
33999         LDKInit ret_var = Init_clone(arg);
34000         int64_t ret_ref = 0;
34001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34002         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34003         return ret_ref;
34004 }
34005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34006         LDKInit arg_conv;
34007         arg_conv.inner = untag_ptr(arg);
34008         arg_conv.is_owned = ptr_is_owned(arg);
34009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34010         arg_conv.is_owned = false;
34011         int64_t ret_conv = Init_clone_ptr(&arg_conv);
34012         return ret_conv;
34013 }
34014
34015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34016         LDKInit orig_conv;
34017         orig_conv.inner = untag_ptr(orig);
34018         orig_conv.is_owned = ptr_is_owned(orig);
34019         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34020         orig_conv.is_owned = false;
34021         LDKInit ret_var = Init_clone(&orig_conv);
34022         int64_t ret_ref = 0;
34023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34024         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34025         return ret_ref;
34026 }
34027
34028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34029         LDKInit a_conv;
34030         a_conv.inner = untag_ptr(a);
34031         a_conv.is_owned = ptr_is_owned(a);
34032         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34033         a_conv.is_owned = false;
34034         LDKInit b_conv;
34035         b_conv.inner = untag_ptr(b);
34036         b_conv.is_owned = ptr_is_owned(b);
34037         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34038         b_conv.is_owned = false;
34039         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
34040         return ret_conv;
34041 }
34042
34043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34044         LDKErrorMessage this_obj_conv;
34045         this_obj_conv.inner = untag_ptr(this_obj);
34046         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34048         ErrorMessage_free(this_obj_conv);
34049 }
34050
34051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34052         LDKErrorMessage this_ptr_conv;
34053         this_ptr_conv.inner = untag_ptr(this_ptr);
34054         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34056         this_ptr_conv.is_owned = false;
34057         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34058         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
34059         return ret_arr;
34060 }
34061
34062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34063         LDKErrorMessage this_ptr_conv;
34064         this_ptr_conv.inner = untag_ptr(this_ptr);
34065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34067         this_ptr_conv.is_owned = false;
34068         LDKThirtyTwoBytes val_ref;
34069         CHECK((*env)->GetArrayLength(env, val) == 32);
34070         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34071         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
34072 }
34073
34074 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34075         LDKErrorMessage this_ptr_conv;
34076         this_ptr_conv.inner = untag_ptr(this_ptr);
34077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34079         this_ptr_conv.is_owned = false;
34080         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
34081         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34082         Str_free(ret_str);
34083         return ret_conv;
34084 }
34085
34086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34087         LDKErrorMessage this_ptr_conv;
34088         this_ptr_conv.inner = untag_ptr(this_ptr);
34089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34091         this_ptr_conv.is_owned = false;
34092         LDKStr val_conv = java_to_owned_str(env, val);
34093         ErrorMessage_set_data(&this_ptr_conv, val_conv);
34094 }
34095
34096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34097         LDKThirtyTwoBytes channel_id_arg_ref;
34098         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34099         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34100         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34101         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
34102         int64_t ret_ref = 0;
34103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34104         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34105         return ret_ref;
34106 }
34107
34108 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
34109         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
34110         int64_t ret_ref = 0;
34111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34113         return ret_ref;
34114 }
34115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34116         LDKErrorMessage arg_conv;
34117         arg_conv.inner = untag_ptr(arg);
34118         arg_conv.is_owned = ptr_is_owned(arg);
34119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34120         arg_conv.is_owned = false;
34121         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
34122         return ret_conv;
34123 }
34124
34125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34126         LDKErrorMessage orig_conv;
34127         orig_conv.inner = untag_ptr(orig);
34128         orig_conv.is_owned = ptr_is_owned(orig);
34129         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34130         orig_conv.is_owned = false;
34131         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
34132         int64_t ret_ref = 0;
34133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34135         return ret_ref;
34136 }
34137
34138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34139         LDKErrorMessage a_conv;
34140         a_conv.inner = untag_ptr(a);
34141         a_conv.is_owned = ptr_is_owned(a);
34142         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34143         a_conv.is_owned = false;
34144         LDKErrorMessage b_conv;
34145         b_conv.inner = untag_ptr(b);
34146         b_conv.is_owned = ptr_is_owned(b);
34147         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34148         b_conv.is_owned = false;
34149         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
34150         return ret_conv;
34151 }
34152
34153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34154         LDKWarningMessage this_obj_conv;
34155         this_obj_conv.inner = untag_ptr(this_obj);
34156         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34158         WarningMessage_free(this_obj_conv);
34159 }
34160
34161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34162         LDKWarningMessage this_ptr_conv;
34163         this_ptr_conv.inner = untag_ptr(this_ptr);
34164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34166         this_ptr_conv.is_owned = false;
34167         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
34169         return ret_arr;
34170 }
34171
34172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34173         LDKWarningMessage this_ptr_conv;
34174         this_ptr_conv.inner = untag_ptr(this_ptr);
34175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34177         this_ptr_conv.is_owned = false;
34178         LDKThirtyTwoBytes val_ref;
34179         CHECK((*env)->GetArrayLength(env, val) == 32);
34180         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34181         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
34182 }
34183
34184 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34185         LDKWarningMessage this_ptr_conv;
34186         this_ptr_conv.inner = untag_ptr(this_ptr);
34187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34189         this_ptr_conv.is_owned = false;
34190         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
34191         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34192         Str_free(ret_str);
34193         return ret_conv;
34194 }
34195
34196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34197         LDKWarningMessage this_ptr_conv;
34198         this_ptr_conv.inner = untag_ptr(this_ptr);
34199         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34201         this_ptr_conv.is_owned = false;
34202         LDKStr val_conv = java_to_owned_str(env, val);
34203         WarningMessage_set_data(&this_ptr_conv, val_conv);
34204 }
34205
34206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34207         LDKThirtyTwoBytes channel_id_arg_ref;
34208         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34209         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34210         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34211         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
34212         int64_t ret_ref = 0;
34213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34215         return ret_ref;
34216 }
34217
34218 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
34219         LDKWarningMessage ret_var = WarningMessage_clone(arg);
34220         int64_t ret_ref = 0;
34221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34223         return ret_ref;
34224 }
34225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34226         LDKWarningMessage arg_conv;
34227         arg_conv.inner = untag_ptr(arg);
34228         arg_conv.is_owned = ptr_is_owned(arg);
34229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34230         arg_conv.is_owned = false;
34231         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
34232         return ret_conv;
34233 }
34234
34235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34236         LDKWarningMessage orig_conv;
34237         orig_conv.inner = untag_ptr(orig);
34238         orig_conv.is_owned = ptr_is_owned(orig);
34239         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34240         orig_conv.is_owned = false;
34241         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
34242         int64_t ret_ref = 0;
34243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34245         return ret_ref;
34246 }
34247
34248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34249         LDKWarningMessage a_conv;
34250         a_conv.inner = untag_ptr(a);
34251         a_conv.is_owned = ptr_is_owned(a);
34252         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34253         a_conv.is_owned = false;
34254         LDKWarningMessage b_conv;
34255         b_conv.inner = untag_ptr(b);
34256         b_conv.is_owned = ptr_is_owned(b);
34257         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34258         b_conv.is_owned = false;
34259         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
34260         return ret_conv;
34261 }
34262
34263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34264         LDKPing this_obj_conv;
34265         this_obj_conv.inner = untag_ptr(this_obj);
34266         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34268         Ping_free(this_obj_conv);
34269 }
34270
34271 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34272         LDKPing this_ptr_conv;
34273         this_ptr_conv.inner = untag_ptr(this_ptr);
34274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34276         this_ptr_conv.is_owned = false;
34277         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
34278         return ret_conv;
34279 }
34280
34281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34282         LDKPing this_ptr_conv;
34283         this_ptr_conv.inner = untag_ptr(this_ptr);
34284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34286         this_ptr_conv.is_owned = false;
34287         Ping_set_ponglen(&this_ptr_conv, val);
34288 }
34289
34290 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34291         LDKPing this_ptr_conv;
34292         this_ptr_conv.inner = untag_ptr(this_ptr);
34293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34295         this_ptr_conv.is_owned = false;
34296         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
34297         return ret_conv;
34298 }
34299
34300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34301         LDKPing this_ptr_conv;
34302         this_ptr_conv.inner = untag_ptr(this_ptr);
34303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34305         this_ptr_conv.is_owned = false;
34306         Ping_set_byteslen(&this_ptr_conv, val);
34307 }
34308
34309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
34310         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
34311         int64_t ret_ref = 0;
34312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34314         return ret_ref;
34315 }
34316
34317 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
34318         LDKPing ret_var = Ping_clone(arg);
34319         int64_t ret_ref = 0;
34320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34322         return ret_ref;
34323 }
34324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34325         LDKPing arg_conv;
34326         arg_conv.inner = untag_ptr(arg);
34327         arg_conv.is_owned = ptr_is_owned(arg);
34328         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34329         arg_conv.is_owned = false;
34330         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
34331         return ret_conv;
34332 }
34333
34334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34335         LDKPing orig_conv;
34336         orig_conv.inner = untag_ptr(orig);
34337         orig_conv.is_owned = ptr_is_owned(orig);
34338         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34339         orig_conv.is_owned = false;
34340         LDKPing ret_var = Ping_clone(&orig_conv);
34341         int64_t ret_ref = 0;
34342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34344         return ret_ref;
34345 }
34346
34347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34348         LDKPing a_conv;
34349         a_conv.inner = untag_ptr(a);
34350         a_conv.is_owned = ptr_is_owned(a);
34351         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34352         a_conv.is_owned = false;
34353         LDKPing b_conv;
34354         b_conv.inner = untag_ptr(b);
34355         b_conv.is_owned = ptr_is_owned(b);
34356         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34357         b_conv.is_owned = false;
34358         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
34359         return ret_conv;
34360 }
34361
34362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34363         LDKPong this_obj_conv;
34364         this_obj_conv.inner = untag_ptr(this_obj);
34365         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34367         Pong_free(this_obj_conv);
34368 }
34369
34370 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34371         LDKPong this_ptr_conv;
34372         this_ptr_conv.inner = untag_ptr(this_ptr);
34373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34375         this_ptr_conv.is_owned = false;
34376         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
34377         return ret_conv;
34378 }
34379
34380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34381         LDKPong this_ptr_conv;
34382         this_ptr_conv.inner = untag_ptr(this_ptr);
34383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34385         this_ptr_conv.is_owned = false;
34386         Pong_set_byteslen(&this_ptr_conv, val);
34387 }
34388
34389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
34390         LDKPong ret_var = Pong_new(byteslen_arg);
34391         int64_t ret_ref = 0;
34392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34394         return ret_ref;
34395 }
34396
34397 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
34398         LDKPong ret_var = Pong_clone(arg);
34399         int64_t ret_ref = 0;
34400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34402         return ret_ref;
34403 }
34404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34405         LDKPong arg_conv;
34406         arg_conv.inner = untag_ptr(arg);
34407         arg_conv.is_owned = ptr_is_owned(arg);
34408         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34409         arg_conv.is_owned = false;
34410         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
34411         return ret_conv;
34412 }
34413
34414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34415         LDKPong orig_conv;
34416         orig_conv.inner = untag_ptr(orig);
34417         orig_conv.is_owned = ptr_is_owned(orig);
34418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34419         orig_conv.is_owned = false;
34420         LDKPong ret_var = Pong_clone(&orig_conv);
34421         int64_t ret_ref = 0;
34422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34424         return ret_ref;
34425 }
34426
34427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34428         LDKPong a_conv;
34429         a_conv.inner = untag_ptr(a);
34430         a_conv.is_owned = ptr_is_owned(a);
34431         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34432         a_conv.is_owned = false;
34433         LDKPong b_conv;
34434         b_conv.inner = untag_ptr(b);
34435         b_conv.is_owned = ptr_is_owned(b);
34436         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34437         b_conv.is_owned = false;
34438         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
34439         return ret_conv;
34440 }
34441
34442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34443         LDKOpenChannel this_obj_conv;
34444         this_obj_conv.inner = untag_ptr(this_obj);
34445         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34447         OpenChannel_free(this_obj_conv);
34448 }
34449
34450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34451         LDKOpenChannel this_ptr_conv;
34452         this_ptr_conv.inner = untag_ptr(this_ptr);
34453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34455         this_ptr_conv.is_owned = false;
34456         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34457         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
34458         return ret_arr;
34459 }
34460
34461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34462         LDKOpenChannel this_ptr_conv;
34463         this_ptr_conv.inner = untag_ptr(this_ptr);
34464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34466         this_ptr_conv.is_owned = false;
34467         LDKThirtyTwoBytes val_ref;
34468         CHECK((*env)->GetArrayLength(env, val) == 32);
34469         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34470         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
34471 }
34472
34473 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34474         LDKOpenChannel this_ptr_conv;
34475         this_ptr_conv.inner = untag_ptr(this_ptr);
34476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34478         this_ptr_conv.is_owned = false;
34479         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
34481         return ret_arr;
34482 }
34483
34484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34485         LDKOpenChannel this_ptr_conv;
34486         this_ptr_conv.inner = untag_ptr(this_ptr);
34487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34489         this_ptr_conv.is_owned = false;
34490         LDKThirtyTwoBytes val_ref;
34491         CHECK((*env)->GetArrayLength(env, val) == 32);
34492         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34493         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
34494 }
34495
34496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34497         LDKOpenChannel this_ptr_conv;
34498         this_ptr_conv.inner = untag_ptr(this_ptr);
34499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34501         this_ptr_conv.is_owned = false;
34502         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
34503         return ret_conv;
34504 }
34505
34506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34507         LDKOpenChannel this_ptr_conv;
34508         this_ptr_conv.inner = untag_ptr(this_ptr);
34509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34511         this_ptr_conv.is_owned = false;
34512         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
34513 }
34514
34515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34516         LDKOpenChannel this_ptr_conv;
34517         this_ptr_conv.inner = untag_ptr(this_ptr);
34518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34520         this_ptr_conv.is_owned = false;
34521         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
34522         return ret_conv;
34523 }
34524
34525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34526         LDKOpenChannel this_ptr_conv;
34527         this_ptr_conv.inner = untag_ptr(this_ptr);
34528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34530         this_ptr_conv.is_owned = false;
34531         OpenChannel_set_push_msat(&this_ptr_conv, val);
34532 }
34533
34534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34535         LDKOpenChannel this_ptr_conv;
34536         this_ptr_conv.inner = untag_ptr(this_ptr);
34537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34539         this_ptr_conv.is_owned = false;
34540         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
34541         return ret_conv;
34542 }
34543
34544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34545         LDKOpenChannel this_ptr_conv;
34546         this_ptr_conv.inner = untag_ptr(this_ptr);
34547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34549         this_ptr_conv.is_owned = false;
34550         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
34551 }
34552
34553 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) {
34554         LDKOpenChannel this_ptr_conv;
34555         this_ptr_conv.inner = untag_ptr(this_ptr);
34556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34558         this_ptr_conv.is_owned = false;
34559         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
34560         return ret_conv;
34561 }
34562
34563 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) {
34564         LDKOpenChannel this_ptr_conv;
34565         this_ptr_conv.inner = untag_ptr(this_ptr);
34566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34568         this_ptr_conv.is_owned = false;
34569         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
34570 }
34571
34572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34573         LDKOpenChannel this_ptr_conv;
34574         this_ptr_conv.inner = untag_ptr(this_ptr);
34575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34577         this_ptr_conv.is_owned = false;
34578         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
34579         return ret_conv;
34580 }
34581
34582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34583         LDKOpenChannel this_ptr_conv;
34584         this_ptr_conv.inner = untag_ptr(this_ptr);
34585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34587         this_ptr_conv.is_owned = false;
34588         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
34589 }
34590
34591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34592         LDKOpenChannel this_ptr_conv;
34593         this_ptr_conv.inner = untag_ptr(this_ptr);
34594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34596         this_ptr_conv.is_owned = false;
34597         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
34598         return ret_conv;
34599 }
34600
34601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34602         LDKOpenChannel this_ptr_conv;
34603         this_ptr_conv.inner = untag_ptr(this_ptr);
34604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34606         this_ptr_conv.is_owned = false;
34607         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
34608 }
34609
34610 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
34611         LDKOpenChannel this_ptr_conv;
34612         this_ptr_conv.inner = untag_ptr(this_ptr);
34613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34615         this_ptr_conv.is_owned = false;
34616         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
34617         return ret_conv;
34618 }
34619
34620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34621         LDKOpenChannel this_ptr_conv;
34622         this_ptr_conv.inner = untag_ptr(this_ptr);
34623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34625         this_ptr_conv.is_owned = false;
34626         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
34627 }
34628
34629 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
34630         LDKOpenChannel this_ptr_conv;
34631         this_ptr_conv.inner = untag_ptr(this_ptr);
34632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34634         this_ptr_conv.is_owned = false;
34635         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
34636         return ret_conv;
34637 }
34638
34639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34640         LDKOpenChannel this_ptr_conv;
34641         this_ptr_conv.inner = untag_ptr(this_ptr);
34642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34644         this_ptr_conv.is_owned = false;
34645         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
34646 }
34647
34648 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34649         LDKOpenChannel this_ptr_conv;
34650         this_ptr_conv.inner = untag_ptr(this_ptr);
34651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34653         this_ptr_conv.is_owned = false;
34654         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
34655         return ret_conv;
34656 }
34657
34658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34659         LDKOpenChannel this_ptr_conv;
34660         this_ptr_conv.inner = untag_ptr(this_ptr);
34661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34663         this_ptr_conv.is_owned = false;
34664         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
34665 }
34666
34667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
34668         LDKOpenChannel this_ptr_conv;
34669         this_ptr_conv.inner = untag_ptr(this_ptr);
34670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34672         this_ptr_conv.is_owned = false;
34673         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
34675         return ret_arr;
34676 }
34677
34678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34679         LDKOpenChannel this_ptr_conv;
34680         this_ptr_conv.inner = untag_ptr(this_ptr);
34681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34683         this_ptr_conv.is_owned = false;
34684         LDKPublicKey val_ref;
34685         CHECK((*env)->GetArrayLength(env, val) == 33);
34686         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34687         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
34688 }
34689
34690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34691         LDKOpenChannel this_ptr_conv;
34692         this_ptr_conv.inner = untag_ptr(this_ptr);
34693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34695         this_ptr_conv.is_owned = false;
34696         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34697         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
34698         return ret_arr;
34699 }
34700
34701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34702         LDKOpenChannel this_ptr_conv;
34703         this_ptr_conv.inner = untag_ptr(this_ptr);
34704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34706         this_ptr_conv.is_owned = false;
34707         LDKPublicKey val_ref;
34708         CHECK((*env)->GetArrayLength(env, val) == 33);
34709         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34710         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
34711 }
34712
34713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34714         LDKOpenChannel this_ptr_conv;
34715         this_ptr_conv.inner = untag_ptr(this_ptr);
34716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34718         this_ptr_conv.is_owned = false;
34719         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34720         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
34721         return ret_arr;
34722 }
34723
34724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34725         LDKOpenChannel this_ptr_conv;
34726         this_ptr_conv.inner = untag_ptr(this_ptr);
34727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34729         this_ptr_conv.is_owned = false;
34730         LDKPublicKey val_ref;
34731         CHECK((*env)->GetArrayLength(env, val) == 33);
34732         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34733         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
34734 }
34735
34736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34737         LDKOpenChannel this_ptr_conv;
34738         this_ptr_conv.inner = untag_ptr(this_ptr);
34739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34741         this_ptr_conv.is_owned = false;
34742         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34743         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
34744         return ret_arr;
34745 }
34746
34747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34748         LDKOpenChannel this_ptr_conv;
34749         this_ptr_conv.inner = untag_ptr(this_ptr);
34750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34752         this_ptr_conv.is_owned = false;
34753         LDKPublicKey val_ref;
34754         CHECK((*env)->GetArrayLength(env, val) == 33);
34755         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34756         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34757 }
34758
34759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34760         LDKOpenChannel this_ptr_conv;
34761         this_ptr_conv.inner = untag_ptr(this_ptr);
34762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34764         this_ptr_conv.is_owned = false;
34765         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34766         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
34767         return ret_arr;
34768 }
34769
34770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34771         LDKOpenChannel this_ptr_conv;
34772         this_ptr_conv.inner = untag_ptr(this_ptr);
34773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34775         this_ptr_conv.is_owned = false;
34776         LDKPublicKey val_ref;
34777         CHECK((*env)->GetArrayLength(env, val) == 33);
34778         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34779         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
34780 }
34781
34782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34783         LDKOpenChannel this_ptr_conv;
34784         this_ptr_conv.inner = untag_ptr(this_ptr);
34785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34787         this_ptr_conv.is_owned = false;
34788         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34789         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
34790         return ret_arr;
34791 }
34792
34793 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) {
34794         LDKOpenChannel this_ptr_conv;
34795         this_ptr_conv.inner = untag_ptr(this_ptr);
34796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34798         this_ptr_conv.is_owned = false;
34799         LDKPublicKey val_ref;
34800         CHECK((*env)->GetArrayLength(env, val) == 33);
34801         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34802         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
34803 }
34804
34805 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
34806         LDKOpenChannel this_ptr_conv;
34807         this_ptr_conv.inner = untag_ptr(this_ptr);
34808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34810         this_ptr_conv.is_owned = false;
34811         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
34812         return ret_conv;
34813 }
34814
34815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
34816         LDKOpenChannel this_ptr_conv;
34817         this_ptr_conv.inner = untag_ptr(this_ptr);
34818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34820         this_ptr_conv.is_owned = false;
34821         OpenChannel_set_channel_flags(&this_ptr_conv, val);
34822 }
34823
34824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
34825         LDKOpenChannel this_ptr_conv;
34826         this_ptr_conv.inner = untag_ptr(this_ptr);
34827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34829         this_ptr_conv.is_owned = false;
34830         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
34831         int64_t ret_ref = 0;
34832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34834         return ret_ref;
34835 }
34836
34837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34838         LDKOpenChannel this_ptr_conv;
34839         this_ptr_conv.inner = untag_ptr(this_ptr);
34840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34842         this_ptr_conv.is_owned = false;
34843         LDKChannelTypeFeatures val_conv;
34844         val_conv.inner = untag_ptr(val);
34845         val_conv.is_owned = ptr_is_owned(val);
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34847         val_conv = ChannelTypeFeatures_clone(&val_conv);
34848         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
34849 }
34850
34851 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
34852         LDKOpenChannel ret_var = OpenChannel_clone(arg);
34853         int64_t ret_ref = 0;
34854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34855         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34856         return ret_ref;
34857 }
34858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34859         LDKOpenChannel arg_conv;
34860         arg_conv.inner = untag_ptr(arg);
34861         arg_conv.is_owned = ptr_is_owned(arg);
34862         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34863         arg_conv.is_owned = false;
34864         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
34865         return ret_conv;
34866 }
34867
34868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34869         LDKOpenChannel orig_conv;
34870         orig_conv.inner = untag_ptr(orig);
34871         orig_conv.is_owned = ptr_is_owned(orig);
34872         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34873         orig_conv.is_owned = false;
34874         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
34875         int64_t ret_ref = 0;
34876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34878         return ret_ref;
34879 }
34880
34881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34882         LDKOpenChannel a_conv;
34883         a_conv.inner = untag_ptr(a);
34884         a_conv.is_owned = ptr_is_owned(a);
34885         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34886         a_conv.is_owned = false;
34887         LDKOpenChannel b_conv;
34888         b_conv.inner = untag_ptr(b);
34889         b_conv.is_owned = ptr_is_owned(b);
34890         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34891         b_conv.is_owned = false;
34892         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
34893         return ret_conv;
34894 }
34895
34896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34897         LDKAcceptChannel this_obj_conv;
34898         this_obj_conv.inner = untag_ptr(this_obj);
34899         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34901         AcceptChannel_free(this_obj_conv);
34902 }
34903
34904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34905         LDKAcceptChannel this_ptr_conv;
34906         this_ptr_conv.inner = untag_ptr(this_ptr);
34907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34909         this_ptr_conv.is_owned = false;
34910         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
34912         return ret_arr;
34913 }
34914
34915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34916         LDKAcceptChannel this_ptr_conv;
34917         this_ptr_conv.inner = untag_ptr(this_ptr);
34918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34920         this_ptr_conv.is_owned = false;
34921         LDKThirtyTwoBytes val_ref;
34922         CHECK((*env)->GetArrayLength(env, val) == 32);
34923         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34924         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
34925 }
34926
34927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34928         LDKAcceptChannel this_ptr_conv;
34929         this_ptr_conv.inner = untag_ptr(this_ptr);
34930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34932         this_ptr_conv.is_owned = false;
34933         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
34934         return ret_conv;
34935 }
34936
34937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34938         LDKAcceptChannel this_ptr_conv;
34939         this_ptr_conv.inner = untag_ptr(this_ptr);
34940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34942         this_ptr_conv.is_owned = false;
34943         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
34944 }
34945
34946 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) {
34947         LDKAcceptChannel this_ptr_conv;
34948         this_ptr_conv.inner = untag_ptr(this_ptr);
34949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34951         this_ptr_conv.is_owned = false;
34952         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
34953         return ret_conv;
34954 }
34955
34956 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) {
34957         LDKAcceptChannel this_ptr_conv;
34958         this_ptr_conv.inner = untag_ptr(this_ptr);
34959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34961         this_ptr_conv.is_owned = false;
34962         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
34963 }
34964
34965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34966         LDKAcceptChannel this_ptr_conv;
34967         this_ptr_conv.inner = untag_ptr(this_ptr);
34968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34970         this_ptr_conv.is_owned = false;
34971         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
34972         return ret_conv;
34973 }
34974
34975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34976         LDKAcceptChannel this_ptr_conv;
34977         this_ptr_conv.inner = untag_ptr(this_ptr);
34978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34980         this_ptr_conv.is_owned = false;
34981         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
34982 }
34983
34984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34985         LDKAcceptChannel this_ptr_conv;
34986         this_ptr_conv.inner = untag_ptr(this_ptr);
34987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34989         this_ptr_conv.is_owned = false;
34990         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
34991         return ret_conv;
34992 }
34993
34994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34995         LDKAcceptChannel this_ptr_conv;
34996         this_ptr_conv.inner = untag_ptr(this_ptr);
34997         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34999         this_ptr_conv.is_owned = false;
35000         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35001 }
35002
35003 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
35004         LDKAcceptChannel this_ptr_conv;
35005         this_ptr_conv.inner = untag_ptr(this_ptr);
35006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35008         this_ptr_conv.is_owned = false;
35009         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
35010         return ret_conv;
35011 }
35012
35013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35014         LDKAcceptChannel this_ptr_conv;
35015         this_ptr_conv.inner = untag_ptr(this_ptr);
35016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35018         this_ptr_conv.is_owned = false;
35019         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
35020 }
35021
35022 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35023         LDKAcceptChannel this_ptr_conv;
35024         this_ptr_conv.inner = untag_ptr(this_ptr);
35025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35027         this_ptr_conv.is_owned = false;
35028         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
35029         return ret_conv;
35030 }
35031
35032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35033         LDKAcceptChannel this_ptr_conv;
35034         this_ptr_conv.inner = untag_ptr(this_ptr);
35035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35037         this_ptr_conv.is_owned = false;
35038         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
35039 }
35040
35041 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35042         LDKAcceptChannel this_ptr_conv;
35043         this_ptr_conv.inner = untag_ptr(this_ptr);
35044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35046         this_ptr_conv.is_owned = false;
35047         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
35048         return ret_conv;
35049 }
35050
35051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35052         LDKAcceptChannel this_ptr_conv;
35053         this_ptr_conv.inner = untag_ptr(this_ptr);
35054         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35056         this_ptr_conv.is_owned = false;
35057         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35058 }
35059
35060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35061         LDKAcceptChannel this_ptr_conv;
35062         this_ptr_conv.inner = untag_ptr(this_ptr);
35063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35065         this_ptr_conv.is_owned = false;
35066         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35068         return ret_arr;
35069 }
35070
35071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35072         LDKAcceptChannel this_ptr_conv;
35073         this_ptr_conv.inner = untag_ptr(this_ptr);
35074         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35076         this_ptr_conv.is_owned = false;
35077         LDKPublicKey val_ref;
35078         CHECK((*env)->GetArrayLength(env, val) == 33);
35079         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35080         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35081 }
35082
35083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35084         LDKAcceptChannel this_ptr_conv;
35085         this_ptr_conv.inner = untag_ptr(this_ptr);
35086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35088         this_ptr_conv.is_owned = false;
35089         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35091         return ret_arr;
35092 }
35093
35094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35095         LDKAcceptChannel this_ptr_conv;
35096         this_ptr_conv.inner = untag_ptr(this_ptr);
35097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35099         this_ptr_conv.is_owned = false;
35100         LDKPublicKey val_ref;
35101         CHECK((*env)->GetArrayLength(env, val) == 33);
35102         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35103         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35104 }
35105
35106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35107         LDKAcceptChannel this_ptr_conv;
35108         this_ptr_conv.inner = untag_ptr(this_ptr);
35109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35111         this_ptr_conv.is_owned = false;
35112         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
35114         return ret_arr;
35115 }
35116
35117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35118         LDKAcceptChannel this_ptr_conv;
35119         this_ptr_conv.inner = untag_ptr(this_ptr);
35120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35122         this_ptr_conv.is_owned = false;
35123         LDKPublicKey val_ref;
35124         CHECK((*env)->GetArrayLength(env, val) == 33);
35125         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35126         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
35127 }
35128
35129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35130         LDKAcceptChannel this_ptr_conv;
35131         this_ptr_conv.inner = untag_ptr(this_ptr);
35132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35134         this_ptr_conv.is_owned = false;
35135         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35137         return ret_arr;
35138 }
35139
35140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35141         LDKAcceptChannel this_ptr_conv;
35142         this_ptr_conv.inner = untag_ptr(this_ptr);
35143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35145         this_ptr_conv.is_owned = false;
35146         LDKPublicKey val_ref;
35147         CHECK((*env)->GetArrayLength(env, val) == 33);
35148         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35149         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35150 }
35151
35152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35153         LDKAcceptChannel this_ptr_conv;
35154         this_ptr_conv.inner = untag_ptr(this_ptr);
35155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35157         this_ptr_conv.is_owned = false;
35158         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35159         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35160         return ret_arr;
35161 }
35162
35163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35164         LDKAcceptChannel this_ptr_conv;
35165         this_ptr_conv.inner = untag_ptr(this_ptr);
35166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35168         this_ptr_conv.is_owned = false;
35169         LDKPublicKey val_ref;
35170         CHECK((*env)->GetArrayLength(env, val) == 33);
35171         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35172         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35173 }
35174
35175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35176         LDKAcceptChannel this_ptr_conv;
35177         this_ptr_conv.inner = untag_ptr(this_ptr);
35178         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35180         this_ptr_conv.is_owned = false;
35181         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35183         return ret_arr;
35184 }
35185
35186 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) {
35187         LDKAcceptChannel this_ptr_conv;
35188         this_ptr_conv.inner = untag_ptr(this_ptr);
35189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35191         this_ptr_conv.is_owned = false;
35192         LDKPublicKey val_ref;
35193         CHECK((*env)->GetArrayLength(env, val) == 33);
35194         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35195         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35196 }
35197
35198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35199         LDKAcceptChannel this_ptr_conv;
35200         this_ptr_conv.inner = untag_ptr(this_ptr);
35201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35203         this_ptr_conv.is_owned = false;
35204         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
35205         int64_t ret_ref = 0;
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35207         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35208         return ret_ref;
35209 }
35210
35211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35212         LDKAcceptChannel this_ptr_conv;
35213         this_ptr_conv.inner = untag_ptr(this_ptr);
35214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35216         this_ptr_conv.is_owned = false;
35217         LDKChannelTypeFeatures val_conv;
35218         val_conv.inner = untag_ptr(val);
35219         val_conv.is_owned = ptr_is_owned(val);
35220         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35221         val_conv = ChannelTypeFeatures_clone(&val_conv);
35222         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
35223 }
35224
35225 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
35226         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
35227         int64_t ret_ref = 0;
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35229         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35230         return ret_ref;
35231 }
35232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35233         LDKAcceptChannel arg_conv;
35234         arg_conv.inner = untag_ptr(arg);
35235         arg_conv.is_owned = ptr_is_owned(arg);
35236         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35237         arg_conv.is_owned = false;
35238         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
35239         return ret_conv;
35240 }
35241
35242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35243         LDKAcceptChannel orig_conv;
35244         orig_conv.inner = untag_ptr(orig);
35245         orig_conv.is_owned = ptr_is_owned(orig);
35246         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35247         orig_conv.is_owned = false;
35248         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
35249         int64_t ret_ref = 0;
35250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35251         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35252         return ret_ref;
35253 }
35254
35255 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35256         LDKAcceptChannel a_conv;
35257         a_conv.inner = untag_ptr(a);
35258         a_conv.is_owned = ptr_is_owned(a);
35259         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35260         a_conv.is_owned = false;
35261         LDKAcceptChannel b_conv;
35262         b_conv.inner = untag_ptr(b);
35263         b_conv.is_owned = ptr_is_owned(b);
35264         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35265         b_conv.is_owned = false;
35266         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
35267         return ret_conv;
35268 }
35269
35270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35271         LDKFundingCreated this_obj_conv;
35272         this_obj_conv.inner = untag_ptr(this_obj);
35273         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35275         FundingCreated_free(this_obj_conv);
35276 }
35277
35278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35279         LDKFundingCreated this_ptr_conv;
35280         this_ptr_conv.inner = untag_ptr(this_ptr);
35281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35283         this_ptr_conv.is_owned = false;
35284         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35285         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
35286         return ret_arr;
35287 }
35288
35289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35290         LDKFundingCreated this_ptr_conv;
35291         this_ptr_conv.inner = untag_ptr(this_ptr);
35292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35294         this_ptr_conv.is_owned = false;
35295         LDKThirtyTwoBytes val_ref;
35296         CHECK((*env)->GetArrayLength(env, val) == 32);
35297         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35298         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
35299 }
35300
35301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
35302         LDKFundingCreated this_ptr_conv;
35303         this_ptr_conv.inner = untag_ptr(this_ptr);
35304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35306         this_ptr_conv.is_owned = false;
35307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
35309         return ret_arr;
35310 }
35311
35312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35313         LDKFundingCreated this_ptr_conv;
35314         this_ptr_conv.inner = untag_ptr(this_ptr);
35315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35317         this_ptr_conv.is_owned = false;
35318         LDKThirtyTwoBytes val_ref;
35319         CHECK((*env)->GetArrayLength(env, val) == 32);
35320         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35321         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
35322 }
35323
35324 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
35325         LDKFundingCreated this_ptr_conv;
35326         this_ptr_conv.inner = untag_ptr(this_ptr);
35327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35329         this_ptr_conv.is_owned = false;
35330         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
35331         return ret_conv;
35332 }
35333
35334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35335         LDKFundingCreated this_ptr_conv;
35336         this_ptr_conv.inner = untag_ptr(this_ptr);
35337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35339         this_ptr_conv.is_owned = false;
35340         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
35341 }
35342
35343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35344         LDKFundingCreated this_ptr_conv;
35345         this_ptr_conv.inner = untag_ptr(this_ptr);
35346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35348         this_ptr_conv.is_owned = false;
35349         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35350         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
35351         return ret_arr;
35352 }
35353
35354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35355         LDKFundingCreated this_ptr_conv;
35356         this_ptr_conv.inner = untag_ptr(this_ptr);
35357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35359         this_ptr_conv.is_owned = false;
35360         LDKSignature val_ref;
35361         CHECK((*env)->GetArrayLength(env, val) == 64);
35362         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35363         FundingCreated_set_signature(&this_ptr_conv, val_ref);
35364 }
35365
35366 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) {
35367         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
35368         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
35369         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
35370         LDKThirtyTwoBytes funding_txid_arg_ref;
35371         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
35372         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
35373         LDKSignature signature_arg_ref;
35374         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35375         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35376         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
35377         int64_t ret_ref = 0;
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35380         return ret_ref;
35381 }
35382
35383 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
35384         LDKFundingCreated ret_var = FundingCreated_clone(arg);
35385         int64_t ret_ref = 0;
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35388         return ret_ref;
35389 }
35390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35391         LDKFundingCreated arg_conv;
35392         arg_conv.inner = untag_ptr(arg);
35393         arg_conv.is_owned = ptr_is_owned(arg);
35394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35395         arg_conv.is_owned = false;
35396         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
35397         return ret_conv;
35398 }
35399
35400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35401         LDKFundingCreated orig_conv;
35402         orig_conv.inner = untag_ptr(orig);
35403         orig_conv.is_owned = ptr_is_owned(orig);
35404         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35405         orig_conv.is_owned = false;
35406         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
35407         int64_t ret_ref = 0;
35408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35409         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35410         return ret_ref;
35411 }
35412
35413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35414         LDKFundingCreated a_conv;
35415         a_conv.inner = untag_ptr(a);
35416         a_conv.is_owned = ptr_is_owned(a);
35417         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35418         a_conv.is_owned = false;
35419         LDKFundingCreated b_conv;
35420         b_conv.inner = untag_ptr(b);
35421         b_conv.is_owned = ptr_is_owned(b);
35422         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35423         b_conv.is_owned = false;
35424         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
35425         return ret_conv;
35426 }
35427
35428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35429         LDKFundingSigned this_obj_conv;
35430         this_obj_conv.inner = untag_ptr(this_obj);
35431         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35433         FundingSigned_free(this_obj_conv);
35434 }
35435
35436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35437         LDKFundingSigned this_ptr_conv;
35438         this_ptr_conv.inner = untag_ptr(this_ptr);
35439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35441         this_ptr_conv.is_owned = false;
35442         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35443         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
35444         return ret_arr;
35445 }
35446
35447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35448         LDKFundingSigned this_ptr_conv;
35449         this_ptr_conv.inner = untag_ptr(this_ptr);
35450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35452         this_ptr_conv.is_owned = false;
35453         LDKThirtyTwoBytes val_ref;
35454         CHECK((*env)->GetArrayLength(env, val) == 32);
35455         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35456         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
35457 }
35458
35459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35460         LDKFundingSigned this_ptr_conv;
35461         this_ptr_conv.inner = untag_ptr(this_ptr);
35462         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35464         this_ptr_conv.is_owned = false;
35465         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35466         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
35467         return ret_arr;
35468 }
35469
35470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35471         LDKFundingSigned this_ptr_conv;
35472         this_ptr_conv.inner = untag_ptr(this_ptr);
35473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35475         this_ptr_conv.is_owned = false;
35476         LDKSignature val_ref;
35477         CHECK((*env)->GetArrayLength(env, val) == 64);
35478         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35479         FundingSigned_set_signature(&this_ptr_conv, val_ref);
35480 }
35481
35482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
35483         LDKThirtyTwoBytes channel_id_arg_ref;
35484         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35485         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35486         LDKSignature signature_arg_ref;
35487         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35488         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35489         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
35490         int64_t ret_ref = 0;
35491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35493         return ret_ref;
35494 }
35495
35496 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
35497         LDKFundingSigned ret_var = FundingSigned_clone(arg);
35498         int64_t ret_ref = 0;
35499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35500         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35501         return ret_ref;
35502 }
35503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35504         LDKFundingSigned arg_conv;
35505         arg_conv.inner = untag_ptr(arg);
35506         arg_conv.is_owned = ptr_is_owned(arg);
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35508         arg_conv.is_owned = false;
35509         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
35510         return ret_conv;
35511 }
35512
35513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35514         LDKFundingSigned orig_conv;
35515         orig_conv.inner = untag_ptr(orig);
35516         orig_conv.is_owned = ptr_is_owned(orig);
35517         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35518         orig_conv.is_owned = false;
35519         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
35520         int64_t ret_ref = 0;
35521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35523         return ret_ref;
35524 }
35525
35526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35527         LDKFundingSigned a_conv;
35528         a_conv.inner = untag_ptr(a);
35529         a_conv.is_owned = ptr_is_owned(a);
35530         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35531         a_conv.is_owned = false;
35532         LDKFundingSigned b_conv;
35533         b_conv.inner = untag_ptr(b);
35534         b_conv.is_owned = ptr_is_owned(b);
35535         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35536         b_conv.is_owned = false;
35537         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
35538         return ret_conv;
35539 }
35540
35541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35542         LDKChannelReady this_obj_conv;
35543         this_obj_conv.inner = untag_ptr(this_obj);
35544         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35546         ChannelReady_free(this_obj_conv);
35547 }
35548
35549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35550         LDKChannelReady this_ptr_conv;
35551         this_ptr_conv.inner = untag_ptr(this_ptr);
35552         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35554         this_ptr_conv.is_owned = false;
35555         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
35557         return ret_arr;
35558 }
35559
35560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35561         LDKChannelReady this_ptr_conv;
35562         this_ptr_conv.inner = untag_ptr(this_ptr);
35563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35565         this_ptr_conv.is_owned = false;
35566         LDKThirtyTwoBytes val_ref;
35567         CHECK((*env)->GetArrayLength(env, val) == 32);
35568         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35569         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
35570 }
35571
35572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35573         LDKChannelReady this_ptr_conv;
35574         this_ptr_conv.inner = untag_ptr(this_ptr);
35575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35577         this_ptr_conv.is_owned = false;
35578         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
35580         return ret_arr;
35581 }
35582
35583 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) {
35584         LDKChannelReady this_ptr_conv;
35585         this_ptr_conv.inner = untag_ptr(this_ptr);
35586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35588         this_ptr_conv.is_owned = false;
35589         LDKPublicKey val_ref;
35590         CHECK((*env)->GetArrayLength(env, val) == 33);
35591         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35592         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
35593 }
35594
35595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35596         LDKChannelReady this_ptr_conv;
35597         this_ptr_conv.inner = untag_ptr(this_ptr);
35598         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35600         this_ptr_conv.is_owned = false;
35601         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35602         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
35603         int64_t ret_ref = tag_ptr(ret_copy, true);
35604         return ret_ref;
35605 }
35606
35607 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) {
35608         LDKChannelReady this_ptr_conv;
35609         this_ptr_conv.inner = untag_ptr(this_ptr);
35610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35612         this_ptr_conv.is_owned = false;
35613         void* val_ptr = untag_ptr(val);
35614         CHECK_ACCESS(val_ptr);
35615         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35616         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
35617         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
35618 }
35619
35620 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) {
35621         LDKThirtyTwoBytes channel_id_arg_ref;
35622         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35623         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35624         LDKPublicKey next_per_commitment_point_arg_ref;
35625         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
35626         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
35627         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
35628         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
35629         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
35630         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
35631         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
35632         int64_t ret_ref = 0;
35633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35635         return ret_ref;
35636 }
35637
35638 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
35639         LDKChannelReady ret_var = ChannelReady_clone(arg);
35640         int64_t ret_ref = 0;
35641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35642         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35643         return ret_ref;
35644 }
35645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35646         LDKChannelReady arg_conv;
35647         arg_conv.inner = untag_ptr(arg);
35648         arg_conv.is_owned = ptr_is_owned(arg);
35649         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35650         arg_conv.is_owned = false;
35651         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
35652         return ret_conv;
35653 }
35654
35655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35656         LDKChannelReady orig_conv;
35657         orig_conv.inner = untag_ptr(orig);
35658         orig_conv.is_owned = ptr_is_owned(orig);
35659         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35660         orig_conv.is_owned = false;
35661         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
35662         int64_t ret_ref = 0;
35663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35665         return ret_ref;
35666 }
35667
35668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35669         LDKChannelReady a_conv;
35670         a_conv.inner = untag_ptr(a);
35671         a_conv.is_owned = ptr_is_owned(a);
35672         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35673         a_conv.is_owned = false;
35674         LDKChannelReady b_conv;
35675         b_conv.inner = untag_ptr(b);
35676         b_conv.is_owned = ptr_is_owned(b);
35677         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35678         b_conv.is_owned = false;
35679         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
35680         return ret_conv;
35681 }
35682
35683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35684         LDKShutdown this_obj_conv;
35685         this_obj_conv.inner = untag_ptr(this_obj);
35686         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35688         Shutdown_free(this_obj_conv);
35689 }
35690
35691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35692         LDKShutdown this_ptr_conv;
35693         this_ptr_conv.inner = untag_ptr(this_ptr);
35694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35696         this_ptr_conv.is_owned = false;
35697         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
35699         return ret_arr;
35700 }
35701
35702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35703         LDKShutdown this_ptr_conv;
35704         this_ptr_conv.inner = untag_ptr(this_ptr);
35705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35707         this_ptr_conv.is_owned = false;
35708         LDKThirtyTwoBytes val_ref;
35709         CHECK((*env)->GetArrayLength(env, val) == 32);
35710         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35711         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
35712 }
35713
35714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35715         LDKShutdown this_ptr_conv;
35716         this_ptr_conv.inner = untag_ptr(this_ptr);
35717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35719         this_ptr_conv.is_owned = false;
35720         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
35721         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35722         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35723         return ret_arr;
35724 }
35725
35726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35727         LDKShutdown this_ptr_conv;
35728         this_ptr_conv.inner = untag_ptr(this_ptr);
35729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35731         this_ptr_conv.is_owned = false;
35732         LDKCVec_u8Z val_ref;
35733         val_ref.datalen = (*env)->GetArrayLength(env, val);
35734         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35735         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35736         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
35737 }
35738
35739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
35740         LDKThirtyTwoBytes channel_id_arg_ref;
35741         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35742         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35743         LDKCVec_u8Z scriptpubkey_arg_ref;
35744         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
35745         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35746         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
35747         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
35748         int64_t ret_ref = 0;
35749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35751         return ret_ref;
35752 }
35753
35754 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
35755         LDKShutdown ret_var = Shutdown_clone(arg);
35756         int64_t ret_ref = 0;
35757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35759         return ret_ref;
35760 }
35761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35762         LDKShutdown arg_conv;
35763         arg_conv.inner = untag_ptr(arg);
35764         arg_conv.is_owned = ptr_is_owned(arg);
35765         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35766         arg_conv.is_owned = false;
35767         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
35768         return ret_conv;
35769 }
35770
35771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35772         LDKShutdown orig_conv;
35773         orig_conv.inner = untag_ptr(orig);
35774         orig_conv.is_owned = ptr_is_owned(orig);
35775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35776         orig_conv.is_owned = false;
35777         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
35778         int64_t ret_ref = 0;
35779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35781         return ret_ref;
35782 }
35783
35784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35785         LDKShutdown a_conv;
35786         a_conv.inner = untag_ptr(a);
35787         a_conv.is_owned = ptr_is_owned(a);
35788         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35789         a_conv.is_owned = false;
35790         LDKShutdown b_conv;
35791         b_conv.inner = untag_ptr(b);
35792         b_conv.is_owned = ptr_is_owned(b);
35793         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35794         b_conv.is_owned = false;
35795         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
35796         return ret_conv;
35797 }
35798
35799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35800         LDKClosingSignedFeeRange this_obj_conv;
35801         this_obj_conv.inner = untag_ptr(this_obj);
35802         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35804         ClosingSignedFeeRange_free(this_obj_conv);
35805 }
35806
35807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35808         LDKClosingSignedFeeRange this_ptr_conv;
35809         this_ptr_conv.inner = untag_ptr(this_ptr);
35810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35812         this_ptr_conv.is_owned = false;
35813         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
35814         return ret_conv;
35815 }
35816
35817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35818         LDKClosingSignedFeeRange this_ptr_conv;
35819         this_ptr_conv.inner = untag_ptr(this_ptr);
35820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35822         this_ptr_conv.is_owned = false;
35823         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
35824 }
35825
35826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35827         LDKClosingSignedFeeRange this_ptr_conv;
35828         this_ptr_conv.inner = untag_ptr(this_ptr);
35829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35831         this_ptr_conv.is_owned = false;
35832         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
35833         return ret_conv;
35834 }
35835
35836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35837         LDKClosingSignedFeeRange this_ptr_conv;
35838         this_ptr_conv.inner = untag_ptr(this_ptr);
35839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35841         this_ptr_conv.is_owned = false;
35842         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
35843 }
35844
35845 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) {
35846         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
35847         int64_t ret_ref = 0;
35848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35850         return ret_ref;
35851 }
35852
35853 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
35854         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
35855         int64_t ret_ref = 0;
35856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35858         return ret_ref;
35859 }
35860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35861         LDKClosingSignedFeeRange arg_conv;
35862         arg_conv.inner = untag_ptr(arg);
35863         arg_conv.is_owned = ptr_is_owned(arg);
35864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35865         arg_conv.is_owned = false;
35866         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
35867         return ret_conv;
35868 }
35869
35870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35871         LDKClosingSignedFeeRange orig_conv;
35872         orig_conv.inner = untag_ptr(orig);
35873         orig_conv.is_owned = ptr_is_owned(orig);
35874         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35875         orig_conv.is_owned = false;
35876         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
35877         int64_t ret_ref = 0;
35878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35880         return ret_ref;
35881 }
35882
35883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35884         LDKClosingSignedFeeRange a_conv;
35885         a_conv.inner = untag_ptr(a);
35886         a_conv.is_owned = ptr_is_owned(a);
35887         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35888         a_conv.is_owned = false;
35889         LDKClosingSignedFeeRange b_conv;
35890         b_conv.inner = untag_ptr(b);
35891         b_conv.is_owned = ptr_is_owned(b);
35892         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35893         b_conv.is_owned = false;
35894         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
35895         return ret_conv;
35896 }
35897
35898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35899         LDKClosingSigned this_obj_conv;
35900         this_obj_conv.inner = untag_ptr(this_obj);
35901         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35903         ClosingSigned_free(this_obj_conv);
35904 }
35905
35906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35907         LDKClosingSigned this_ptr_conv;
35908         this_ptr_conv.inner = untag_ptr(this_ptr);
35909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35911         this_ptr_conv.is_owned = false;
35912         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35913         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
35914         return ret_arr;
35915 }
35916
35917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35918         LDKClosingSigned this_ptr_conv;
35919         this_ptr_conv.inner = untag_ptr(this_ptr);
35920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35922         this_ptr_conv.is_owned = false;
35923         LDKThirtyTwoBytes val_ref;
35924         CHECK((*env)->GetArrayLength(env, val) == 32);
35925         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35926         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
35927 }
35928
35929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35930         LDKClosingSigned this_ptr_conv;
35931         this_ptr_conv.inner = untag_ptr(this_ptr);
35932         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35934         this_ptr_conv.is_owned = false;
35935         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
35936         return ret_conv;
35937 }
35938
35939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35940         LDKClosingSigned this_ptr_conv;
35941         this_ptr_conv.inner = untag_ptr(this_ptr);
35942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35944         this_ptr_conv.is_owned = false;
35945         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
35946 }
35947
35948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35949         LDKClosingSigned this_ptr_conv;
35950         this_ptr_conv.inner = untag_ptr(this_ptr);
35951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35953         this_ptr_conv.is_owned = false;
35954         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35955         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
35956         return ret_arr;
35957 }
35958
35959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35960         LDKClosingSigned this_ptr_conv;
35961         this_ptr_conv.inner = untag_ptr(this_ptr);
35962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35964         this_ptr_conv.is_owned = false;
35965         LDKSignature val_ref;
35966         CHECK((*env)->GetArrayLength(env, val) == 64);
35967         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35968         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
35969 }
35970
35971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
35972         LDKClosingSigned this_ptr_conv;
35973         this_ptr_conv.inner = untag_ptr(this_ptr);
35974         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35976         this_ptr_conv.is_owned = false;
35977         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
35978         int64_t ret_ref = 0;
35979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35981         return ret_ref;
35982 }
35983
35984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35985         LDKClosingSigned this_ptr_conv;
35986         this_ptr_conv.inner = untag_ptr(this_ptr);
35987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35989         this_ptr_conv.is_owned = false;
35990         LDKClosingSignedFeeRange val_conv;
35991         val_conv.inner = untag_ptr(val);
35992         val_conv.is_owned = ptr_is_owned(val);
35993         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35994         val_conv = ClosingSignedFeeRange_clone(&val_conv);
35995         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
35996 }
35997
35998 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) {
35999         LDKThirtyTwoBytes channel_id_arg_ref;
36000         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36001         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36002         LDKSignature signature_arg_ref;
36003         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36004         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36005         LDKClosingSignedFeeRange fee_range_arg_conv;
36006         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
36007         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
36008         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
36009         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
36010         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
36011         int64_t ret_ref = 0;
36012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36014         return ret_ref;
36015 }
36016
36017 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
36018         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
36019         int64_t ret_ref = 0;
36020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36022         return ret_ref;
36023 }
36024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36025         LDKClosingSigned arg_conv;
36026         arg_conv.inner = untag_ptr(arg);
36027         arg_conv.is_owned = ptr_is_owned(arg);
36028         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36029         arg_conv.is_owned = false;
36030         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
36031         return ret_conv;
36032 }
36033
36034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36035         LDKClosingSigned orig_conv;
36036         orig_conv.inner = untag_ptr(orig);
36037         orig_conv.is_owned = ptr_is_owned(orig);
36038         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36039         orig_conv.is_owned = false;
36040         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
36041         int64_t ret_ref = 0;
36042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36043         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36044         return ret_ref;
36045 }
36046
36047 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36048         LDKClosingSigned a_conv;
36049         a_conv.inner = untag_ptr(a);
36050         a_conv.is_owned = ptr_is_owned(a);
36051         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36052         a_conv.is_owned = false;
36053         LDKClosingSigned b_conv;
36054         b_conv.inner = untag_ptr(b);
36055         b_conv.is_owned = ptr_is_owned(b);
36056         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36057         b_conv.is_owned = false;
36058         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
36059         return ret_conv;
36060 }
36061
36062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36063         LDKUpdateAddHTLC this_obj_conv;
36064         this_obj_conv.inner = untag_ptr(this_obj);
36065         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36067         UpdateAddHTLC_free(this_obj_conv);
36068 }
36069
36070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36071         LDKUpdateAddHTLC this_ptr_conv;
36072         this_ptr_conv.inner = untag_ptr(this_ptr);
36073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36075         this_ptr_conv.is_owned = false;
36076         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36077         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
36078         return ret_arr;
36079 }
36080
36081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36082         LDKUpdateAddHTLC this_ptr_conv;
36083         this_ptr_conv.inner = untag_ptr(this_ptr);
36084         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36086         this_ptr_conv.is_owned = false;
36087         LDKThirtyTwoBytes val_ref;
36088         CHECK((*env)->GetArrayLength(env, val) == 32);
36089         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36090         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
36091 }
36092
36093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36094         LDKUpdateAddHTLC this_ptr_conv;
36095         this_ptr_conv.inner = untag_ptr(this_ptr);
36096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36098         this_ptr_conv.is_owned = false;
36099         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
36100         return ret_conv;
36101 }
36102
36103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36104         LDKUpdateAddHTLC this_ptr_conv;
36105         this_ptr_conv.inner = untag_ptr(this_ptr);
36106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36108         this_ptr_conv.is_owned = false;
36109         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
36110 }
36111
36112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36113         LDKUpdateAddHTLC this_ptr_conv;
36114         this_ptr_conv.inner = untag_ptr(this_ptr);
36115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36117         this_ptr_conv.is_owned = false;
36118         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
36119         return ret_conv;
36120 }
36121
36122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36123         LDKUpdateAddHTLC this_ptr_conv;
36124         this_ptr_conv.inner = untag_ptr(this_ptr);
36125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36127         this_ptr_conv.is_owned = false;
36128         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
36129 }
36130
36131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36132         LDKUpdateAddHTLC this_ptr_conv;
36133         this_ptr_conv.inner = untag_ptr(this_ptr);
36134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36136         this_ptr_conv.is_owned = false;
36137         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
36139         return ret_arr;
36140 }
36141
36142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36143         LDKUpdateAddHTLC this_ptr_conv;
36144         this_ptr_conv.inner = untag_ptr(this_ptr);
36145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36147         this_ptr_conv.is_owned = false;
36148         LDKThirtyTwoBytes val_ref;
36149         CHECK((*env)->GetArrayLength(env, val) == 32);
36150         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36151         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
36152 }
36153
36154 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36155         LDKUpdateAddHTLC this_ptr_conv;
36156         this_ptr_conv.inner = untag_ptr(this_ptr);
36157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36159         this_ptr_conv.is_owned = false;
36160         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
36161         return ret_conv;
36162 }
36163
36164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36165         LDKUpdateAddHTLC this_ptr_conv;
36166         this_ptr_conv.inner = untag_ptr(this_ptr);
36167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36169         this_ptr_conv.is_owned = false;
36170         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
36171 }
36172
36173 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
36174         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
36175         int64_t ret_ref = 0;
36176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36178         return ret_ref;
36179 }
36180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36181         LDKUpdateAddHTLC arg_conv;
36182         arg_conv.inner = untag_ptr(arg);
36183         arg_conv.is_owned = ptr_is_owned(arg);
36184         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36185         arg_conv.is_owned = false;
36186         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
36187         return ret_conv;
36188 }
36189
36190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36191         LDKUpdateAddHTLC orig_conv;
36192         orig_conv.inner = untag_ptr(orig);
36193         orig_conv.is_owned = ptr_is_owned(orig);
36194         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36195         orig_conv.is_owned = false;
36196         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
36197         int64_t ret_ref = 0;
36198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36200         return ret_ref;
36201 }
36202
36203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36204         LDKUpdateAddHTLC a_conv;
36205         a_conv.inner = untag_ptr(a);
36206         a_conv.is_owned = ptr_is_owned(a);
36207         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36208         a_conv.is_owned = false;
36209         LDKUpdateAddHTLC b_conv;
36210         b_conv.inner = untag_ptr(b);
36211         b_conv.is_owned = ptr_is_owned(b);
36212         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36213         b_conv.is_owned = false;
36214         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
36215         return ret_conv;
36216 }
36217
36218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36219         LDKOnionMessage this_obj_conv;
36220         this_obj_conv.inner = untag_ptr(this_obj);
36221         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36223         OnionMessage_free(this_obj_conv);
36224 }
36225
36226 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36227         LDKOnionMessage this_ptr_conv;
36228         this_ptr_conv.inner = untag_ptr(this_ptr);
36229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36231         this_ptr_conv.is_owned = false;
36232         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36233         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
36234         return ret_arr;
36235 }
36236
36237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36238         LDKOnionMessage this_ptr_conv;
36239         this_ptr_conv.inner = untag_ptr(this_ptr);
36240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36242         this_ptr_conv.is_owned = false;
36243         LDKPublicKey val_ref;
36244         CHECK((*env)->GetArrayLength(env, val) == 33);
36245         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36246         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
36247 }
36248
36249 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
36250         LDKOnionMessage ret_var = OnionMessage_clone(arg);
36251         int64_t ret_ref = 0;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36253         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36254         return ret_ref;
36255 }
36256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36257         LDKOnionMessage arg_conv;
36258         arg_conv.inner = untag_ptr(arg);
36259         arg_conv.is_owned = ptr_is_owned(arg);
36260         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36261         arg_conv.is_owned = false;
36262         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
36263         return ret_conv;
36264 }
36265
36266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36267         LDKOnionMessage orig_conv;
36268         orig_conv.inner = untag_ptr(orig);
36269         orig_conv.is_owned = ptr_is_owned(orig);
36270         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36271         orig_conv.is_owned = false;
36272         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
36273         int64_t ret_ref = 0;
36274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36275         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36276         return ret_ref;
36277 }
36278
36279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36280         LDKOnionMessage a_conv;
36281         a_conv.inner = untag_ptr(a);
36282         a_conv.is_owned = ptr_is_owned(a);
36283         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36284         a_conv.is_owned = false;
36285         LDKOnionMessage b_conv;
36286         b_conv.inner = untag_ptr(b);
36287         b_conv.is_owned = ptr_is_owned(b);
36288         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36289         b_conv.is_owned = false;
36290         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
36291         return ret_conv;
36292 }
36293
36294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36295         LDKUpdateFulfillHTLC this_obj_conv;
36296         this_obj_conv.inner = untag_ptr(this_obj);
36297         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36299         UpdateFulfillHTLC_free(this_obj_conv);
36300 }
36301
36302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36303         LDKUpdateFulfillHTLC this_ptr_conv;
36304         this_ptr_conv.inner = untag_ptr(this_ptr);
36305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36307         this_ptr_conv.is_owned = false;
36308         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36309         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
36310         return ret_arr;
36311 }
36312
36313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36314         LDKUpdateFulfillHTLC this_ptr_conv;
36315         this_ptr_conv.inner = untag_ptr(this_ptr);
36316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36318         this_ptr_conv.is_owned = false;
36319         LDKThirtyTwoBytes val_ref;
36320         CHECK((*env)->GetArrayLength(env, val) == 32);
36321         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36322         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
36323 }
36324
36325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36326         LDKUpdateFulfillHTLC this_ptr_conv;
36327         this_ptr_conv.inner = untag_ptr(this_ptr);
36328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36330         this_ptr_conv.is_owned = false;
36331         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
36332         return ret_conv;
36333 }
36334
36335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36336         LDKUpdateFulfillHTLC this_ptr_conv;
36337         this_ptr_conv.inner = untag_ptr(this_ptr);
36338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36340         this_ptr_conv.is_owned = false;
36341         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
36342 }
36343
36344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
36345         LDKUpdateFulfillHTLC this_ptr_conv;
36346         this_ptr_conv.inner = untag_ptr(this_ptr);
36347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36349         this_ptr_conv.is_owned = false;
36350         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36351         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
36352         return ret_arr;
36353 }
36354
36355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36356         LDKUpdateFulfillHTLC this_ptr_conv;
36357         this_ptr_conv.inner = untag_ptr(this_ptr);
36358         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36360         this_ptr_conv.is_owned = false;
36361         LDKThirtyTwoBytes val_ref;
36362         CHECK((*env)->GetArrayLength(env, val) == 32);
36363         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36364         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
36365 }
36366
36367 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) {
36368         LDKThirtyTwoBytes channel_id_arg_ref;
36369         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36370         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36371         LDKThirtyTwoBytes payment_preimage_arg_ref;
36372         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
36373         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
36374         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
36375         int64_t ret_ref = 0;
36376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36378         return ret_ref;
36379 }
36380
36381 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
36382         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
36383         int64_t ret_ref = 0;
36384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36386         return ret_ref;
36387 }
36388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36389         LDKUpdateFulfillHTLC arg_conv;
36390         arg_conv.inner = untag_ptr(arg);
36391         arg_conv.is_owned = ptr_is_owned(arg);
36392         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36393         arg_conv.is_owned = false;
36394         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
36395         return ret_conv;
36396 }
36397
36398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36399         LDKUpdateFulfillHTLC orig_conv;
36400         orig_conv.inner = untag_ptr(orig);
36401         orig_conv.is_owned = ptr_is_owned(orig);
36402         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36403         orig_conv.is_owned = false;
36404         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
36405         int64_t ret_ref = 0;
36406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36407         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36408         return ret_ref;
36409 }
36410
36411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36412         LDKUpdateFulfillHTLC a_conv;
36413         a_conv.inner = untag_ptr(a);
36414         a_conv.is_owned = ptr_is_owned(a);
36415         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36416         a_conv.is_owned = false;
36417         LDKUpdateFulfillHTLC b_conv;
36418         b_conv.inner = untag_ptr(b);
36419         b_conv.is_owned = ptr_is_owned(b);
36420         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36421         b_conv.is_owned = false;
36422         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
36423         return ret_conv;
36424 }
36425
36426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36427         LDKUpdateFailHTLC this_obj_conv;
36428         this_obj_conv.inner = untag_ptr(this_obj);
36429         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36431         UpdateFailHTLC_free(this_obj_conv);
36432 }
36433
36434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36435         LDKUpdateFailHTLC this_ptr_conv;
36436         this_ptr_conv.inner = untag_ptr(this_ptr);
36437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36439         this_ptr_conv.is_owned = false;
36440         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36441         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
36442         return ret_arr;
36443 }
36444
36445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36446         LDKUpdateFailHTLC this_ptr_conv;
36447         this_ptr_conv.inner = untag_ptr(this_ptr);
36448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36450         this_ptr_conv.is_owned = false;
36451         LDKThirtyTwoBytes val_ref;
36452         CHECK((*env)->GetArrayLength(env, val) == 32);
36453         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36454         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
36455 }
36456
36457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36458         LDKUpdateFailHTLC this_ptr_conv;
36459         this_ptr_conv.inner = untag_ptr(this_ptr);
36460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36462         this_ptr_conv.is_owned = false;
36463         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
36464         return ret_conv;
36465 }
36466
36467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36468         LDKUpdateFailHTLC this_ptr_conv;
36469         this_ptr_conv.inner = untag_ptr(this_ptr);
36470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36472         this_ptr_conv.is_owned = false;
36473         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
36474 }
36475
36476 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
36477         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
36478         int64_t ret_ref = 0;
36479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36481         return ret_ref;
36482 }
36483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36484         LDKUpdateFailHTLC arg_conv;
36485         arg_conv.inner = untag_ptr(arg);
36486         arg_conv.is_owned = ptr_is_owned(arg);
36487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36488         arg_conv.is_owned = false;
36489         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
36490         return ret_conv;
36491 }
36492
36493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36494         LDKUpdateFailHTLC orig_conv;
36495         orig_conv.inner = untag_ptr(orig);
36496         orig_conv.is_owned = ptr_is_owned(orig);
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36498         orig_conv.is_owned = false;
36499         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
36500         int64_t ret_ref = 0;
36501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36503         return ret_ref;
36504 }
36505
36506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36507         LDKUpdateFailHTLC a_conv;
36508         a_conv.inner = untag_ptr(a);
36509         a_conv.is_owned = ptr_is_owned(a);
36510         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36511         a_conv.is_owned = false;
36512         LDKUpdateFailHTLC b_conv;
36513         b_conv.inner = untag_ptr(b);
36514         b_conv.is_owned = ptr_is_owned(b);
36515         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36516         b_conv.is_owned = false;
36517         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
36518         return ret_conv;
36519 }
36520
36521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36522         LDKUpdateFailMalformedHTLC this_obj_conv;
36523         this_obj_conv.inner = untag_ptr(this_obj);
36524         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36526         UpdateFailMalformedHTLC_free(this_obj_conv);
36527 }
36528
36529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36530         LDKUpdateFailMalformedHTLC this_ptr_conv;
36531         this_ptr_conv.inner = untag_ptr(this_ptr);
36532         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36534         this_ptr_conv.is_owned = false;
36535         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
36537         return ret_arr;
36538 }
36539
36540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36541         LDKUpdateFailMalformedHTLC this_ptr_conv;
36542         this_ptr_conv.inner = untag_ptr(this_ptr);
36543         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36545         this_ptr_conv.is_owned = false;
36546         LDKThirtyTwoBytes val_ref;
36547         CHECK((*env)->GetArrayLength(env, val) == 32);
36548         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36549         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
36550 }
36551
36552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36553         LDKUpdateFailMalformedHTLC this_ptr_conv;
36554         this_ptr_conv.inner = untag_ptr(this_ptr);
36555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36557         this_ptr_conv.is_owned = false;
36558         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
36559         return ret_conv;
36560 }
36561
36562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36563         LDKUpdateFailMalformedHTLC this_ptr_conv;
36564         this_ptr_conv.inner = untag_ptr(this_ptr);
36565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36567         this_ptr_conv.is_owned = false;
36568         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
36569 }
36570
36571 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
36572         LDKUpdateFailMalformedHTLC this_ptr_conv;
36573         this_ptr_conv.inner = untag_ptr(this_ptr);
36574         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36576         this_ptr_conv.is_owned = false;
36577         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
36578         return ret_conv;
36579 }
36580
36581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36582         LDKUpdateFailMalformedHTLC this_ptr_conv;
36583         this_ptr_conv.inner = untag_ptr(this_ptr);
36584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36586         this_ptr_conv.is_owned = false;
36587         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
36588 }
36589
36590 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
36591         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
36592         int64_t ret_ref = 0;
36593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36594         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36595         return ret_ref;
36596 }
36597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36598         LDKUpdateFailMalformedHTLC arg_conv;
36599         arg_conv.inner = untag_ptr(arg);
36600         arg_conv.is_owned = ptr_is_owned(arg);
36601         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36602         arg_conv.is_owned = false;
36603         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
36604         return ret_conv;
36605 }
36606
36607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36608         LDKUpdateFailMalformedHTLC orig_conv;
36609         orig_conv.inner = untag_ptr(orig);
36610         orig_conv.is_owned = ptr_is_owned(orig);
36611         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36612         orig_conv.is_owned = false;
36613         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
36614         int64_t ret_ref = 0;
36615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36616         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36617         return ret_ref;
36618 }
36619
36620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36621         LDKUpdateFailMalformedHTLC a_conv;
36622         a_conv.inner = untag_ptr(a);
36623         a_conv.is_owned = ptr_is_owned(a);
36624         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36625         a_conv.is_owned = false;
36626         LDKUpdateFailMalformedHTLC b_conv;
36627         b_conv.inner = untag_ptr(b);
36628         b_conv.is_owned = ptr_is_owned(b);
36629         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36630         b_conv.is_owned = false;
36631         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
36632         return ret_conv;
36633 }
36634
36635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36636         LDKCommitmentSigned this_obj_conv;
36637         this_obj_conv.inner = untag_ptr(this_obj);
36638         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36640         CommitmentSigned_free(this_obj_conv);
36641 }
36642
36643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36644         LDKCommitmentSigned this_ptr_conv;
36645         this_ptr_conv.inner = untag_ptr(this_ptr);
36646         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36648         this_ptr_conv.is_owned = false;
36649         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36650         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
36651         return ret_arr;
36652 }
36653
36654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36655         LDKCommitmentSigned this_ptr_conv;
36656         this_ptr_conv.inner = untag_ptr(this_ptr);
36657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36659         this_ptr_conv.is_owned = false;
36660         LDKThirtyTwoBytes val_ref;
36661         CHECK((*env)->GetArrayLength(env, val) == 32);
36662         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36663         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
36664 }
36665
36666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36667         LDKCommitmentSigned this_ptr_conv;
36668         this_ptr_conv.inner = untag_ptr(this_ptr);
36669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36671         this_ptr_conv.is_owned = false;
36672         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36673         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
36674         return ret_arr;
36675 }
36676
36677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36678         LDKCommitmentSigned this_ptr_conv;
36679         this_ptr_conv.inner = untag_ptr(this_ptr);
36680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36682         this_ptr_conv.is_owned = false;
36683         LDKSignature val_ref;
36684         CHECK((*env)->GetArrayLength(env, val) == 64);
36685         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36686         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
36687 }
36688
36689 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
36690         LDKCommitmentSigned this_ptr_conv;
36691         this_ptr_conv.inner = untag_ptr(this_ptr);
36692         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36694         this_ptr_conv.is_owned = false;
36695         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
36696         jobjectArray ret_arr = NULL;
36697         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
36698         ;
36699         for (size_t i = 0; i < ret_var.datalen; i++) {
36700                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
36701                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
36702                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
36703         }
36704         
36705         FREE(ret_var.data);
36706         return ret_arr;
36707 }
36708
36709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
36710         LDKCommitmentSigned this_ptr_conv;
36711         this_ptr_conv.inner = untag_ptr(this_ptr);
36712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36714         this_ptr_conv.is_owned = false;
36715         LDKCVec_SignatureZ val_constr;
36716         val_constr.datalen = (*env)->GetArrayLength(env, val);
36717         if (val_constr.datalen > 0)
36718                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36719         else
36720                 val_constr.data = NULL;
36721         for (size_t i = 0; i < val_constr.datalen; i++) {
36722                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
36723                 LDKSignature val_conv_8_ref;
36724                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
36725                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
36726                 val_constr.data[i] = val_conv_8_ref;
36727         }
36728         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
36729 }
36730
36731 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) {
36732         LDKThirtyTwoBytes channel_id_arg_ref;
36733         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36734         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36735         LDKSignature signature_arg_ref;
36736         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36737         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36738         LDKCVec_SignatureZ htlc_signatures_arg_constr;
36739         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
36740         if (htlc_signatures_arg_constr.datalen > 0)
36741                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36742         else
36743                 htlc_signatures_arg_constr.data = NULL;
36744         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
36745                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
36746                 LDKSignature htlc_signatures_arg_conv_8_ref;
36747                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
36748                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
36749                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
36750         }
36751         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
36752         int64_t ret_ref = 0;
36753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36754         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36755         return ret_ref;
36756 }
36757
36758 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
36759         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
36760         int64_t ret_ref = 0;
36761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36762         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36763         return ret_ref;
36764 }
36765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36766         LDKCommitmentSigned arg_conv;
36767         arg_conv.inner = untag_ptr(arg);
36768         arg_conv.is_owned = ptr_is_owned(arg);
36769         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36770         arg_conv.is_owned = false;
36771         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
36772         return ret_conv;
36773 }
36774
36775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36776         LDKCommitmentSigned orig_conv;
36777         orig_conv.inner = untag_ptr(orig);
36778         orig_conv.is_owned = ptr_is_owned(orig);
36779         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36780         orig_conv.is_owned = false;
36781         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
36782         int64_t ret_ref = 0;
36783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36785         return ret_ref;
36786 }
36787
36788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36789         LDKCommitmentSigned a_conv;
36790         a_conv.inner = untag_ptr(a);
36791         a_conv.is_owned = ptr_is_owned(a);
36792         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36793         a_conv.is_owned = false;
36794         LDKCommitmentSigned b_conv;
36795         b_conv.inner = untag_ptr(b);
36796         b_conv.is_owned = ptr_is_owned(b);
36797         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36798         b_conv.is_owned = false;
36799         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
36800         return ret_conv;
36801 }
36802
36803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36804         LDKRevokeAndACK this_obj_conv;
36805         this_obj_conv.inner = untag_ptr(this_obj);
36806         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36808         RevokeAndACK_free(this_obj_conv);
36809 }
36810
36811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36812         LDKRevokeAndACK this_ptr_conv;
36813         this_ptr_conv.inner = untag_ptr(this_ptr);
36814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36816         this_ptr_conv.is_owned = false;
36817         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
36819         return ret_arr;
36820 }
36821
36822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36823         LDKRevokeAndACK this_ptr_conv;
36824         this_ptr_conv.inner = untag_ptr(this_ptr);
36825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36827         this_ptr_conv.is_owned = false;
36828         LDKThirtyTwoBytes val_ref;
36829         CHECK((*env)->GetArrayLength(env, val) == 32);
36830         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36831         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
36832 }
36833
36834 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
36835         LDKRevokeAndACK this_ptr_conv;
36836         this_ptr_conv.inner = untag_ptr(this_ptr);
36837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36839         this_ptr_conv.is_owned = false;
36840         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36841         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
36842         return ret_arr;
36843 }
36844
36845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36846         LDKRevokeAndACK this_ptr_conv;
36847         this_ptr_conv.inner = untag_ptr(this_ptr);
36848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36850         this_ptr_conv.is_owned = false;
36851         LDKThirtyTwoBytes val_ref;
36852         CHECK((*env)->GetArrayLength(env, val) == 32);
36853         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36854         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
36855 }
36856
36857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36858         LDKRevokeAndACK this_ptr_conv;
36859         this_ptr_conv.inner = untag_ptr(this_ptr);
36860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36862         this_ptr_conv.is_owned = false;
36863         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
36865         return ret_arr;
36866 }
36867
36868 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) {
36869         LDKRevokeAndACK this_ptr_conv;
36870         this_ptr_conv.inner = untag_ptr(this_ptr);
36871         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36873         this_ptr_conv.is_owned = false;
36874         LDKPublicKey val_ref;
36875         CHECK((*env)->GetArrayLength(env, val) == 33);
36876         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36877         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
36878 }
36879
36880 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) {
36881         LDKThirtyTwoBytes channel_id_arg_ref;
36882         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36883         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36884         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
36885         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
36886         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
36887         LDKPublicKey next_per_commitment_point_arg_ref;
36888         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
36889         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
36890         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
36891         int64_t ret_ref = 0;
36892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36893         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36894         return ret_ref;
36895 }
36896
36897 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
36898         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
36899         int64_t ret_ref = 0;
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36902         return ret_ref;
36903 }
36904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36905         LDKRevokeAndACK arg_conv;
36906         arg_conv.inner = untag_ptr(arg);
36907         arg_conv.is_owned = ptr_is_owned(arg);
36908         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36909         arg_conv.is_owned = false;
36910         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
36911         return ret_conv;
36912 }
36913
36914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36915         LDKRevokeAndACK orig_conv;
36916         orig_conv.inner = untag_ptr(orig);
36917         orig_conv.is_owned = ptr_is_owned(orig);
36918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36919         orig_conv.is_owned = false;
36920         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
36921         int64_t ret_ref = 0;
36922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36924         return ret_ref;
36925 }
36926
36927 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36928         LDKRevokeAndACK a_conv;
36929         a_conv.inner = untag_ptr(a);
36930         a_conv.is_owned = ptr_is_owned(a);
36931         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36932         a_conv.is_owned = false;
36933         LDKRevokeAndACK b_conv;
36934         b_conv.inner = untag_ptr(b);
36935         b_conv.is_owned = ptr_is_owned(b);
36936         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36937         b_conv.is_owned = false;
36938         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
36939         return ret_conv;
36940 }
36941
36942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36943         LDKUpdateFee this_obj_conv;
36944         this_obj_conv.inner = untag_ptr(this_obj);
36945         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36947         UpdateFee_free(this_obj_conv);
36948 }
36949
36950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36951         LDKUpdateFee this_ptr_conv;
36952         this_ptr_conv.inner = untag_ptr(this_ptr);
36953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36955         this_ptr_conv.is_owned = false;
36956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
36958         return ret_arr;
36959 }
36960
36961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36962         LDKUpdateFee this_ptr_conv;
36963         this_ptr_conv.inner = untag_ptr(this_ptr);
36964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36966         this_ptr_conv.is_owned = false;
36967         LDKThirtyTwoBytes val_ref;
36968         CHECK((*env)->GetArrayLength(env, val) == 32);
36969         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36970         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
36971 }
36972
36973 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
36974         LDKUpdateFee this_ptr_conv;
36975         this_ptr_conv.inner = untag_ptr(this_ptr);
36976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36978         this_ptr_conv.is_owned = false;
36979         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
36980         return ret_conv;
36981 }
36982
36983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36984         LDKUpdateFee this_ptr_conv;
36985         this_ptr_conv.inner = untag_ptr(this_ptr);
36986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36988         this_ptr_conv.is_owned = false;
36989         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
36990 }
36991
36992 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) {
36993         LDKThirtyTwoBytes channel_id_arg_ref;
36994         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36995         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36996         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
36997         int64_t ret_ref = 0;
36998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37000         return ret_ref;
37001 }
37002
37003 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
37004         LDKUpdateFee ret_var = UpdateFee_clone(arg);
37005         int64_t ret_ref = 0;
37006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37008         return ret_ref;
37009 }
37010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37011         LDKUpdateFee arg_conv;
37012         arg_conv.inner = untag_ptr(arg);
37013         arg_conv.is_owned = ptr_is_owned(arg);
37014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37015         arg_conv.is_owned = false;
37016         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
37017         return ret_conv;
37018 }
37019
37020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37021         LDKUpdateFee orig_conv;
37022         orig_conv.inner = untag_ptr(orig);
37023         orig_conv.is_owned = ptr_is_owned(orig);
37024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37025         orig_conv.is_owned = false;
37026         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
37027         int64_t ret_ref = 0;
37028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37030         return ret_ref;
37031 }
37032
37033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37034         LDKUpdateFee a_conv;
37035         a_conv.inner = untag_ptr(a);
37036         a_conv.is_owned = ptr_is_owned(a);
37037         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37038         a_conv.is_owned = false;
37039         LDKUpdateFee b_conv;
37040         b_conv.inner = untag_ptr(b);
37041         b_conv.is_owned = ptr_is_owned(b);
37042         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37043         b_conv.is_owned = false;
37044         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
37045         return ret_conv;
37046 }
37047
37048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37049         LDKDataLossProtect this_obj_conv;
37050         this_obj_conv.inner = untag_ptr(this_obj);
37051         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37053         DataLossProtect_free(this_obj_conv);
37054 }
37055
37056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37057         LDKDataLossProtect this_ptr_conv;
37058         this_ptr_conv.inner = untag_ptr(this_ptr);
37059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37061         this_ptr_conv.is_owned = false;
37062         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
37064         return ret_arr;
37065 }
37066
37067 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) {
37068         LDKDataLossProtect this_ptr_conv;
37069         this_ptr_conv.inner = untag_ptr(this_ptr);
37070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37072         this_ptr_conv.is_owned = false;
37073         LDKThirtyTwoBytes val_ref;
37074         CHECK((*env)->GetArrayLength(env, val) == 32);
37075         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37076         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
37077 }
37078
37079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37080         LDKDataLossProtect this_ptr_conv;
37081         this_ptr_conv.inner = untag_ptr(this_ptr);
37082         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37084         this_ptr_conv.is_owned = false;
37085         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
37087         return ret_arr;
37088 }
37089
37090 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) {
37091         LDKDataLossProtect this_ptr_conv;
37092         this_ptr_conv.inner = untag_ptr(this_ptr);
37093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37095         this_ptr_conv.is_owned = false;
37096         LDKPublicKey val_ref;
37097         CHECK((*env)->GetArrayLength(env, val) == 33);
37098         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37099         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
37100 }
37101
37102 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) {
37103         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
37104         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
37105         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
37106         LDKPublicKey my_current_per_commitment_point_arg_ref;
37107         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
37108         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
37109         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
37110         int64_t ret_ref = 0;
37111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37113         return ret_ref;
37114 }
37115
37116 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
37117         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
37118         int64_t ret_ref = 0;
37119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37121         return ret_ref;
37122 }
37123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37124         LDKDataLossProtect arg_conv;
37125         arg_conv.inner = untag_ptr(arg);
37126         arg_conv.is_owned = ptr_is_owned(arg);
37127         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37128         arg_conv.is_owned = false;
37129         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
37130         return ret_conv;
37131 }
37132
37133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37134         LDKDataLossProtect orig_conv;
37135         orig_conv.inner = untag_ptr(orig);
37136         orig_conv.is_owned = ptr_is_owned(orig);
37137         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37138         orig_conv.is_owned = false;
37139         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
37140         int64_t ret_ref = 0;
37141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37142         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37143         return ret_ref;
37144 }
37145
37146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37147         LDKDataLossProtect a_conv;
37148         a_conv.inner = untag_ptr(a);
37149         a_conv.is_owned = ptr_is_owned(a);
37150         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37151         a_conv.is_owned = false;
37152         LDKDataLossProtect b_conv;
37153         b_conv.inner = untag_ptr(b);
37154         b_conv.is_owned = ptr_is_owned(b);
37155         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37156         b_conv.is_owned = false;
37157         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
37158         return ret_conv;
37159 }
37160
37161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37162         LDKChannelReestablish this_obj_conv;
37163         this_obj_conv.inner = untag_ptr(this_obj);
37164         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37166         ChannelReestablish_free(this_obj_conv);
37167 }
37168
37169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37170         LDKChannelReestablish this_ptr_conv;
37171         this_ptr_conv.inner = untag_ptr(this_ptr);
37172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37174         this_ptr_conv.is_owned = false;
37175         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37176         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
37177         return ret_arr;
37178 }
37179
37180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37181         LDKChannelReestablish this_ptr_conv;
37182         this_ptr_conv.inner = untag_ptr(this_ptr);
37183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37185         this_ptr_conv.is_owned = false;
37186         LDKThirtyTwoBytes val_ref;
37187         CHECK((*env)->GetArrayLength(env, val) == 32);
37188         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37189         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
37190 }
37191
37192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37193         LDKChannelReestablish this_ptr_conv;
37194         this_ptr_conv.inner = untag_ptr(this_ptr);
37195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37197         this_ptr_conv.is_owned = false;
37198         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
37199         return ret_conv;
37200 }
37201
37202 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) {
37203         LDKChannelReestablish this_ptr_conv;
37204         this_ptr_conv.inner = untag_ptr(this_ptr);
37205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37207         this_ptr_conv.is_owned = false;
37208         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
37209 }
37210
37211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37212         LDKChannelReestablish this_ptr_conv;
37213         this_ptr_conv.inner = untag_ptr(this_ptr);
37214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37216         this_ptr_conv.is_owned = false;
37217         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
37218         return ret_conv;
37219 }
37220
37221 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) {
37222         LDKChannelReestablish this_ptr_conv;
37223         this_ptr_conv.inner = untag_ptr(this_ptr);
37224         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37226         this_ptr_conv.is_owned = false;
37227         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
37228 }
37229
37230 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
37231         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
37232         int64_t ret_ref = 0;
37233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37235         return ret_ref;
37236 }
37237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37238         LDKChannelReestablish arg_conv;
37239         arg_conv.inner = untag_ptr(arg);
37240         arg_conv.is_owned = ptr_is_owned(arg);
37241         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37242         arg_conv.is_owned = false;
37243         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
37244         return ret_conv;
37245 }
37246
37247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37248         LDKChannelReestablish orig_conv;
37249         orig_conv.inner = untag_ptr(orig);
37250         orig_conv.is_owned = ptr_is_owned(orig);
37251         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37252         orig_conv.is_owned = false;
37253         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
37254         int64_t ret_ref = 0;
37255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37257         return ret_ref;
37258 }
37259
37260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37261         LDKChannelReestablish a_conv;
37262         a_conv.inner = untag_ptr(a);
37263         a_conv.is_owned = ptr_is_owned(a);
37264         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37265         a_conv.is_owned = false;
37266         LDKChannelReestablish b_conv;
37267         b_conv.inner = untag_ptr(b);
37268         b_conv.is_owned = ptr_is_owned(b);
37269         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37270         b_conv.is_owned = false;
37271         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
37272         return ret_conv;
37273 }
37274
37275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37276         LDKAnnouncementSignatures this_obj_conv;
37277         this_obj_conv.inner = untag_ptr(this_obj);
37278         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37280         AnnouncementSignatures_free(this_obj_conv);
37281 }
37282
37283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37284         LDKAnnouncementSignatures this_ptr_conv;
37285         this_ptr_conv.inner = untag_ptr(this_ptr);
37286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37288         this_ptr_conv.is_owned = false;
37289         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
37291         return ret_arr;
37292 }
37293
37294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37295         LDKAnnouncementSignatures this_ptr_conv;
37296         this_ptr_conv.inner = untag_ptr(this_ptr);
37297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37299         this_ptr_conv.is_owned = false;
37300         LDKThirtyTwoBytes val_ref;
37301         CHECK((*env)->GetArrayLength(env, val) == 32);
37302         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37303         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
37304 }
37305
37306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37307         LDKAnnouncementSignatures this_ptr_conv;
37308         this_ptr_conv.inner = untag_ptr(this_ptr);
37309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37311         this_ptr_conv.is_owned = false;
37312         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
37313         return ret_conv;
37314 }
37315
37316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37317         LDKAnnouncementSignatures this_ptr_conv;
37318         this_ptr_conv.inner = untag_ptr(this_ptr);
37319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37321         this_ptr_conv.is_owned = false;
37322         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
37323 }
37324
37325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37326         LDKAnnouncementSignatures this_ptr_conv;
37327         this_ptr_conv.inner = untag_ptr(this_ptr);
37328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37330         this_ptr_conv.is_owned = false;
37331         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37332         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
37333         return ret_arr;
37334 }
37335
37336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37337         LDKAnnouncementSignatures this_ptr_conv;
37338         this_ptr_conv.inner = untag_ptr(this_ptr);
37339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37341         this_ptr_conv.is_owned = false;
37342         LDKSignature val_ref;
37343         CHECK((*env)->GetArrayLength(env, val) == 64);
37344         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37345         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
37346 }
37347
37348 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37349         LDKAnnouncementSignatures this_ptr_conv;
37350         this_ptr_conv.inner = untag_ptr(this_ptr);
37351         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37353         this_ptr_conv.is_owned = false;
37354         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37355         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
37356         return ret_arr;
37357 }
37358
37359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37360         LDKAnnouncementSignatures this_ptr_conv;
37361         this_ptr_conv.inner = untag_ptr(this_ptr);
37362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37364         this_ptr_conv.is_owned = false;
37365         LDKSignature val_ref;
37366         CHECK((*env)->GetArrayLength(env, val) == 64);
37367         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37368         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
37369 }
37370
37371 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) {
37372         LDKThirtyTwoBytes channel_id_arg_ref;
37373         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37374         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37375         LDKSignature node_signature_arg_ref;
37376         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
37377         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
37378         LDKSignature bitcoin_signature_arg_ref;
37379         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
37380         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
37381         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
37382         int64_t ret_ref = 0;
37383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37384         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37385         return ret_ref;
37386 }
37387
37388 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
37389         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
37390         int64_t ret_ref = 0;
37391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37393         return ret_ref;
37394 }
37395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37396         LDKAnnouncementSignatures arg_conv;
37397         arg_conv.inner = untag_ptr(arg);
37398         arg_conv.is_owned = ptr_is_owned(arg);
37399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37400         arg_conv.is_owned = false;
37401         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
37402         return ret_conv;
37403 }
37404
37405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37406         LDKAnnouncementSignatures orig_conv;
37407         orig_conv.inner = untag_ptr(orig);
37408         orig_conv.is_owned = ptr_is_owned(orig);
37409         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37410         orig_conv.is_owned = false;
37411         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
37412         int64_t ret_ref = 0;
37413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37415         return ret_ref;
37416 }
37417
37418 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37419         LDKAnnouncementSignatures a_conv;
37420         a_conv.inner = untag_ptr(a);
37421         a_conv.is_owned = ptr_is_owned(a);
37422         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37423         a_conv.is_owned = false;
37424         LDKAnnouncementSignatures b_conv;
37425         b_conv.inner = untag_ptr(b);
37426         b_conv.is_owned = ptr_is_owned(b);
37427         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37428         b_conv.is_owned = false;
37429         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
37430         return ret_conv;
37431 }
37432
37433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37434         if (!ptr_is_owned(this_ptr)) return;
37435         void* this_ptr_ptr = untag_ptr(this_ptr);
37436         CHECK_ACCESS(this_ptr_ptr);
37437         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
37438         FREE(untag_ptr(this_ptr));
37439         NetAddress_free(this_ptr_conv);
37440 }
37441
37442 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
37443         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37444         *ret_copy = NetAddress_clone(arg);
37445         int64_t ret_ref = tag_ptr(ret_copy, true);
37446         return ret_ref;
37447 }
37448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37449         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
37450         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
37451         return ret_conv;
37452 }
37453
37454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37455         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
37456         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37457         *ret_copy = NetAddress_clone(orig_conv);
37458         int64_t ret_ref = tag_ptr(ret_copy, true);
37459         return ret_ref;
37460 }
37461
37462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
37463         LDKFourBytes addr_ref;
37464         CHECK((*env)->GetArrayLength(env, addr) == 4);
37465         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
37466         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37467         *ret_copy = NetAddress_ipv4(addr_ref, port);
37468         int64_t ret_ref = tag_ptr(ret_copy, true);
37469         return ret_ref;
37470 }
37471
37472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
37473         LDKSixteenBytes addr_ref;
37474         CHECK((*env)->GetArrayLength(env, addr) == 16);
37475         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
37476         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37477         *ret_copy = NetAddress_ipv6(addr_ref, port);
37478         int64_t ret_ref = tag_ptr(ret_copy, true);
37479         return ret_ref;
37480 }
37481
37482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
37483         LDKTwelveBytes a_ref;
37484         CHECK((*env)->GetArrayLength(env, a) == 12);
37485         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
37486         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37487         *ret_copy = NetAddress_onion_v2(a_ref);
37488         int64_t ret_ref = tag_ptr(ret_copy, true);
37489         return ret_ref;
37490 }
37491
37492 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) {
37493         LDKThirtyTwoBytes ed25519_pubkey_ref;
37494         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
37495         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
37496         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37497         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
37498         int64_t ret_ref = tag_ptr(ret_copy, true);
37499         return ret_ref;
37500 }
37501
37502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
37503         LDKHostname hostname_conv;
37504         hostname_conv.inner = untag_ptr(hostname);
37505         hostname_conv.is_owned = ptr_is_owned(hostname);
37506         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
37507         hostname_conv = Hostname_clone(&hostname_conv);
37508         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37509         *ret_copy = NetAddress_hostname(hostname_conv, port);
37510         int64_t ret_ref = tag_ptr(ret_copy, true);
37511         return ret_ref;
37512 }
37513
37514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37515         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
37516         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
37517         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
37518         return ret_conv;
37519 }
37520
37521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
37522         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
37523         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
37524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37526         CVec_u8Z_free(ret_var);
37527         return ret_arr;
37528 }
37529
37530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37531         LDKu8slice ser_ref;
37532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37534         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
37535         *ret_conv = NetAddress_read(ser_ref);
37536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37537         return tag_ptr(ret_conv, true);
37538 }
37539
37540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37541         LDKUnsignedNodeAnnouncement this_obj_conv;
37542         this_obj_conv.inner = untag_ptr(this_obj);
37543         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37545         UnsignedNodeAnnouncement_free(this_obj_conv);
37546 }
37547
37548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37549         LDKUnsignedNodeAnnouncement this_ptr_conv;
37550         this_ptr_conv.inner = untag_ptr(this_ptr);
37551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37553         this_ptr_conv.is_owned = false;
37554         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
37555         int64_t ret_ref = 0;
37556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37557         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37558         return ret_ref;
37559 }
37560
37561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37562         LDKUnsignedNodeAnnouncement this_ptr_conv;
37563         this_ptr_conv.inner = untag_ptr(this_ptr);
37564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37566         this_ptr_conv.is_owned = false;
37567         LDKNodeFeatures val_conv;
37568         val_conv.inner = untag_ptr(val);
37569         val_conv.is_owned = ptr_is_owned(val);
37570         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37571         val_conv = NodeFeatures_clone(&val_conv);
37572         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
37573 }
37574
37575 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
37576         LDKUnsignedNodeAnnouncement this_ptr_conv;
37577         this_ptr_conv.inner = untag_ptr(this_ptr);
37578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37580         this_ptr_conv.is_owned = false;
37581         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
37582         return ret_conv;
37583 }
37584
37585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37586         LDKUnsignedNodeAnnouncement this_ptr_conv;
37587         this_ptr_conv.inner = untag_ptr(this_ptr);
37588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37590         this_ptr_conv.is_owned = false;
37591         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
37592 }
37593
37594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37595         LDKUnsignedNodeAnnouncement this_ptr_conv;
37596         this_ptr_conv.inner = untag_ptr(this_ptr);
37597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37599         this_ptr_conv.is_owned = false;
37600         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
37602         return ret_arr;
37603 }
37604
37605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37606         LDKUnsignedNodeAnnouncement this_ptr_conv;
37607         this_ptr_conv.inner = untag_ptr(this_ptr);
37608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37610         this_ptr_conv.is_owned = false;
37611         LDKPublicKey val_ref;
37612         CHECK((*env)->GetArrayLength(env, val) == 33);
37613         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37614         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
37615 }
37616
37617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
37618         LDKUnsignedNodeAnnouncement this_ptr_conv;
37619         this_ptr_conv.inner = untag_ptr(this_ptr);
37620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37622         this_ptr_conv.is_owned = false;
37623         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
37624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
37625         return ret_arr;
37626 }
37627
37628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37629         LDKUnsignedNodeAnnouncement this_ptr_conv;
37630         this_ptr_conv.inner = untag_ptr(this_ptr);
37631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37633         this_ptr_conv.is_owned = false;
37634         LDKThreeBytes val_ref;
37635         CHECK((*env)->GetArrayLength(env, val) == 3);
37636         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
37637         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
37638 }
37639
37640 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
37641         LDKUnsignedNodeAnnouncement this_ptr_conv;
37642         this_ptr_conv.inner = untag_ptr(this_ptr);
37643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37645         this_ptr_conv.is_owned = false;
37646         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
37648         return ret_arr;
37649 }
37650
37651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37652         LDKUnsignedNodeAnnouncement this_ptr_conv;
37653         this_ptr_conv.inner = untag_ptr(this_ptr);
37654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37656         this_ptr_conv.is_owned = false;
37657         LDKThirtyTwoBytes val_ref;
37658         CHECK((*env)->GetArrayLength(env, val) == 32);
37659         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37660         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
37661 }
37662
37663 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
37664         LDKUnsignedNodeAnnouncement this_ptr_conv;
37665         this_ptr_conv.inner = untag_ptr(this_ptr);
37666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37668         this_ptr_conv.is_owned = false;
37669         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
37670         int64_tArray ret_arr = NULL;
37671         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37672         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37673         for (size_t m = 0; m < ret_var.datalen; m++) {
37674                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37675                 *ret_conv_12_copy = ret_var.data[m];
37676                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
37677                 ret_arr_ptr[m] = ret_conv_12_ref;
37678         }
37679         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37680         FREE(ret_var.data);
37681         return ret_arr;
37682 }
37683
37684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37685         LDKUnsignedNodeAnnouncement this_ptr_conv;
37686         this_ptr_conv.inner = untag_ptr(this_ptr);
37687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37689         this_ptr_conv.is_owned = false;
37690         LDKCVec_NetAddressZ val_constr;
37691         val_constr.datalen = (*env)->GetArrayLength(env, val);
37692         if (val_constr.datalen > 0)
37693                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37694         else
37695                 val_constr.data = NULL;
37696         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37697         for (size_t m = 0; m < val_constr.datalen; m++) {
37698                 int64_t val_conv_12 = val_vals[m];
37699                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
37700                 CHECK_ACCESS(val_conv_12_ptr);
37701                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
37702                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
37703                 val_constr.data[m] = val_conv_12_conv;
37704         }
37705         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37706         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
37707 }
37708
37709 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
37710         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
37711         int64_t ret_ref = 0;
37712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37714         return ret_ref;
37715 }
37716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37717         LDKUnsignedNodeAnnouncement arg_conv;
37718         arg_conv.inner = untag_ptr(arg);
37719         arg_conv.is_owned = ptr_is_owned(arg);
37720         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37721         arg_conv.is_owned = false;
37722         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
37723         return ret_conv;
37724 }
37725
37726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37727         LDKUnsignedNodeAnnouncement orig_conv;
37728         orig_conv.inner = untag_ptr(orig);
37729         orig_conv.is_owned = ptr_is_owned(orig);
37730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37731         orig_conv.is_owned = false;
37732         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
37733         int64_t ret_ref = 0;
37734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37736         return ret_ref;
37737 }
37738
37739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37740         LDKUnsignedNodeAnnouncement a_conv;
37741         a_conv.inner = untag_ptr(a);
37742         a_conv.is_owned = ptr_is_owned(a);
37743         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37744         a_conv.is_owned = false;
37745         LDKUnsignedNodeAnnouncement b_conv;
37746         b_conv.inner = untag_ptr(b);
37747         b_conv.is_owned = ptr_is_owned(b);
37748         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37749         b_conv.is_owned = false;
37750         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
37751         return ret_conv;
37752 }
37753
37754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37755         LDKNodeAnnouncement this_obj_conv;
37756         this_obj_conv.inner = untag_ptr(this_obj);
37757         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37759         NodeAnnouncement_free(this_obj_conv);
37760 }
37761
37762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37763         LDKNodeAnnouncement this_ptr_conv;
37764         this_ptr_conv.inner = untag_ptr(this_ptr);
37765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37767         this_ptr_conv.is_owned = false;
37768         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
37770         return ret_arr;
37771 }
37772
37773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37774         LDKNodeAnnouncement this_ptr_conv;
37775         this_ptr_conv.inner = untag_ptr(this_ptr);
37776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37778         this_ptr_conv.is_owned = false;
37779         LDKSignature val_ref;
37780         CHECK((*env)->GetArrayLength(env, val) == 64);
37781         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37782         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
37783 }
37784
37785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
37786         LDKNodeAnnouncement this_ptr_conv;
37787         this_ptr_conv.inner = untag_ptr(this_ptr);
37788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37790         this_ptr_conv.is_owned = false;
37791         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
37792         int64_t ret_ref = 0;
37793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37794         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37795         return ret_ref;
37796 }
37797
37798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37799         LDKNodeAnnouncement this_ptr_conv;
37800         this_ptr_conv.inner = untag_ptr(this_ptr);
37801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37803         this_ptr_conv.is_owned = false;
37804         LDKUnsignedNodeAnnouncement val_conv;
37805         val_conv.inner = untag_ptr(val);
37806         val_conv.is_owned = ptr_is_owned(val);
37807         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37808         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
37809         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
37810 }
37811
37812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
37813         LDKSignature signature_arg_ref;
37814         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37815         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37816         LDKUnsignedNodeAnnouncement contents_arg_conv;
37817         contents_arg_conv.inner = untag_ptr(contents_arg);
37818         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
37819         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
37820         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
37821         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
37822         int64_t ret_ref = 0;
37823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37825         return ret_ref;
37826 }
37827
37828 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
37829         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
37830         int64_t ret_ref = 0;
37831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37833         return ret_ref;
37834 }
37835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37836         LDKNodeAnnouncement arg_conv;
37837         arg_conv.inner = untag_ptr(arg);
37838         arg_conv.is_owned = ptr_is_owned(arg);
37839         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37840         arg_conv.is_owned = false;
37841         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
37842         return ret_conv;
37843 }
37844
37845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37846         LDKNodeAnnouncement orig_conv;
37847         orig_conv.inner = untag_ptr(orig);
37848         orig_conv.is_owned = ptr_is_owned(orig);
37849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37850         orig_conv.is_owned = false;
37851         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
37852         int64_t ret_ref = 0;
37853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37855         return ret_ref;
37856 }
37857
37858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37859         LDKNodeAnnouncement a_conv;
37860         a_conv.inner = untag_ptr(a);
37861         a_conv.is_owned = ptr_is_owned(a);
37862         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37863         a_conv.is_owned = false;
37864         LDKNodeAnnouncement b_conv;
37865         b_conv.inner = untag_ptr(b);
37866         b_conv.is_owned = ptr_is_owned(b);
37867         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37868         b_conv.is_owned = false;
37869         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
37870         return ret_conv;
37871 }
37872
37873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37874         LDKUnsignedChannelAnnouncement this_obj_conv;
37875         this_obj_conv.inner = untag_ptr(this_obj);
37876         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37878         UnsignedChannelAnnouncement_free(this_obj_conv);
37879 }
37880
37881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37882         LDKUnsignedChannelAnnouncement this_ptr_conv;
37883         this_ptr_conv.inner = untag_ptr(this_ptr);
37884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37886         this_ptr_conv.is_owned = false;
37887         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
37888         int64_t ret_ref = 0;
37889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37890         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37891         return ret_ref;
37892 }
37893
37894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37895         LDKUnsignedChannelAnnouncement this_ptr_conv;
37896         this_ptr_conv.inner = untag_ptr(this_ptr);
37897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37899         this_ptr_conv.is_owned = false;
37900         LDKChannelFeatures val_conv;
37901         val_conv.inner = untag_ptr(val);
37902         val_conv.is_owned = ptr_is_owned(val);
37903         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37904         val_conv = ChannelFeatures_clone(&val_conv);
37905         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
37906 }
37907
37908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37909         LDKUnsignedChannelAnnouncement this_ptr_conv;
37910         this_ptr_conv.inner = untag_ptr(this_ptr);
37911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37913         this_ptr_conv.is_owned = false;
37914         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37915         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
37916         return ret_arr;
37917 }
37918
37919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37920         LDKUnsignedChannelAnnouncement this_ptr_conv;
37921         this_ptr_conv.inner = untag_ptr(this_ptr);
37922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37924         this_ptr_conv.is_owned = false;
37925         LDKThirtyTwoBytes val_ref;
37926         CHECK((*env)->GetArrayLength(env, val) == 32);
37927         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37928         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
37929 }
37930
37931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37932         LDKUnsignedChannelAnnouncement this_ptr_conv;
37933         this_ptr_conv.inner = untag_ptr(this_ptr);
37934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37936         this_ptr_conv.is_owned = false;
37937         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
37938         return ret_conv;
37939 }
37940
37941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37942         LDKUnsignedChannelAnnouncement this_ptr_conv;
37943         this_ptr_conv.inner = untag_ptr(this_ptr);
37944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37946         this_ptr_conv.is_owned = false;
37947         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
37948 }
37949
37950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37951         LDKUnsignedChannelAnnouncement this_ptr_conv;
37952         this_ptr_conv.inner = untag_ptr(this_ptr);
37953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37955         this_ptr_conv.is_owned = false;
37956         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
37958         return ret_arr;
37959 }
37960
37961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37962         LDKUnsignedChannelAnnouncement this_ptr_conv;
37963         this_ptr_conv.inner = untag_ptr(this_ptr);
37964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37966         this_ptr_conv.is_owned = false;
37967         LDKPublicKey val_ref;
37968         CHECK((*env)->GetArrayLength(env, val) == 33);
37969         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37970         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
37971 }
37972
37973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
37974         LDKUnsignedChannelAnnouncement this_ptr_conv;
37975         this_ptr_conv.inner = untag_ptr(this_ptr);
37976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37978         this_ptr_conv.is_owned = false;
37979         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37980         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
37981         return ret_arr;
37982 }
37983
37984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37985         LDKUnsignedChannelAnnouncement this_ptr_conv;
37986         this_ptr_conv.inner = untag_ptr(this_ptr);
37987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37989         this_ptr_conv.is_owned = false;
37990         LDKPublicKey val_ref;
37991         CHECK((*env)->GetArrayLength(env, val) == 33);
37992         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37993         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
37994 }
37995
37996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37997         LDKUnsignedChannelAnnouncement this_ptr_conv;
37998         this_ptr_conv.inner = untag_ptr(this_ptr);
37999         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38001         this_ptr_conv.is_owned = false;
38002         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38003         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
38004         return ret_arr;
38005 }
38006
38007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38008         LDKUnsignedChannelAnnouncement this_ptr_conv;
38009         this_ptr_conv.inner = untag_ptr(this_ptr);
38010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38012         this_ptr_conv.is_owned = false;
38013         LDKPublicKey val_ref;
38014         CHECK((*env)->GetArrayLength(env, val) == 33);
38015         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38016         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
38017 }
38018
38019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38020         LDKUnsignedChannelAnnouncement this_ptr_conv;
38021         this_ptr_conv.inner = untag_ptr(this_ptr);
38022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38024         this_ptr_conv.is_owned = false;
38025         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38026         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
38027         return ret_arr;
38028 }
38029
38030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38031         LDKUnsignedChannelAnnouncement this_ptr_conv;
38032         this_ptr_conv.inner = untag_ptr(this_ptr);
38033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38035         this_ptr_conv.is_owned = false;
38036         LDKPublicKey val_ref;
38037         CHECK((*env)->GetArrayLength(env, val) == 33);
38038         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38039         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
38040 }
38041
38042 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
38043         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
38044         int64_t ret_ref = 0;
38045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38046         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38047         return ret_ref;
38048 }
38049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38050         LDKUnsignedChannelAnnouncement arg_conv;
38051         arg_conv.inner = untag_ptr(arg);
38052         arg_conv.is_owned = ptr_is_owned(arg);
38053         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38054         arg_conv.is_owned = false;
38055         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
38056         return ret_conv;
38057 }
38058
38059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38060         LDKUnsignedChannelAnnouncement orig_conv;
38061         orig_conv.inner = untag_ptr(orig);
38062         orig_conv.is_owned = ptr_is_owned(orig);
38063         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38064         orig_conv.is_owned = false;
38065         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
38066         int64_t ret_ref = 0;
38067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38069         return ret_ref;
38070 }
38071
38072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38073         LDKUnsignedChannelAnnouncement a_conv;
38074         a_conv.inner = untag_ptr(a);
38075         a_conv.is_owned = ptr_is_owned(a);
38076         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38077         a_conv.is_owned = false;
38078         LDKUnsignedChannelAnnouncement b_conv;
38079         b_conv.inner = untag_ptr(b);
38080         b_conv.is_owned = ptr_is_owned(b);
38081         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38082         b_conv.is_owned = false;
38083         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
38084         return ret_conv;
38085 }
38086
38087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38088         LDKChannelAnnouncement this_obj_conv;
38089         this_obj_conv.inner = untag_ptr(this_obj);
38090         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38092         ChannelAnnouncement_free(this_obj_conv);
38093 }
38094
38095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38096         LDKChannelAnnouncement this_ptr_conv;
38097         this_ptr_conv.inner = untag_ptr(this_ptr);
38098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38100         this_ptr_conv.is_owned = false;
38101         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
38103         return ret_arr;
38104 }
38105
38106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38107         LDKChannelAnnouncement this_ptr_conv;
38108         this_ptr_conv.inner = untag_ptr(this_ptr);
38109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38111         this_ptr_conv.is_owned = false;
38112         LDKSignature val_ref;
38113         CHECK((*env)->GetArrayLength(env, val) == 64);
38114         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38115         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
38116 }
38117
38118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38119         LDKChannelAnnouncement this_ptr_conv;
38120         this_ptr_conv.inner = untag_ptr(this_ptr);
38121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38123         this_ptr_conv.is_owned = false;
38124         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
38126         return ret_arr;
38127 }
38128
38129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38130         LDKChannelAnnouncement this_ptr_conv;
38131         this_ptr_conv.inner = untag_ptr(this_ptr);
38132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38134         this_ptr_conv.is_owned = false;
38135         LDKSignature val_ref;
38136         CHECK((*env)->GetArrayLength(env, val) == 64);
38137         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38138         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
38139 }
38140
38141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38142         LDKChannelAnnouncement this_ptr_conv;
38143         this_ptr_conv.inner = untag_ptr(this_ptr);
38144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38146         this_ptr_conv.is_owned = false;
38147         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38148         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
38149         return ret_arr;
38150 }
38151
38152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38153         LDKChannelAnnouncement this_ptr_conv;
38154         this_ptr_conv.inner = untag_ptr(this_ptr);
38155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38157         this_ptr_conv.is_owned = false;
38158         LDKSignature val_ref;
38159         CHECK((*env)->GetArrayLength(env, val) == 64);
38160         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38161         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
38162 }
38163
38164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38165         LDKChannelAnnouncement this_ptr_conv;
38166         this_ptr_conv.inner = untag_ptr(this_ptr);
38167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38169         this_ptr_conv.is_owned = false;
38170         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38171         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
38172         return ret_arr;
38173 }
38174
38175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38176         LDKChannelAnnouncement this_ptr_conv;
38177         this_ptr_conv.inner = untag_ptr(this_ptr);
38178         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38180         this_ptr_conv.is_owned = false;
38181         LDKSignature val_ref;
38182         CHECK((*env)->GetArrayLength(env, val) == 64);
38183         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38184         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
38185 }
38186
38187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38188         LDKChannelAnnouncement this_ptr_conv;
38189         this_ptr_conv.inner = untag_ptr(this_ptr);
38190         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38192         this_ptr_conv.is_owned = false;
38193         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
38194         int64_t ret_ref = 0;
38195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38197         return ret_ref;
38198 }
38199
38200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38201         LDKChannelAnnouncement this_ptr_conv;
38202         this_ptr_conv.inner = untag_ptr(this_ptr);
38203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38205         this_ptr_conv.is_owned = false;
38206         LDKUnsignedChannelAnnouncement val_conv;
38207         val_conv.inner = untag_ptr(val);
38208         val_conv.is_owned = ptr_is_owned(val);
38209         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38210         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
38211         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
38212 }
38213
38214 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) {
38215         LDKSignature node_signature_1_arg_ref;
38216         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
38217         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
38218         LDKSignature node_signature_2_arg_ref;
38219         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
38220         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
38221         LDKSignature bitcoin_signature_1_arg_ref;
38222         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
38223         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
38224         LDKSignature bitcoin_signature_2_arg_ref;
38225         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
38226         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
38227         LDKUnsignedChannelAnnouncement contents_arg_conv;
38228         contents_arg_conv.inner = untag_ptr(contents_arg);
38229         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38230         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38231         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
38232         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);
38233         int64_t ret_ref = 0;
38234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38236         return ret_ref;
38237 }
38238
38239 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
38240         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
38241         int64_t ret_ref = 0;
38242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38243         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38244         return ret_ref;
38245 }
38246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38247         LDKChannelAnnouncement arg_conv;
38248         arg_conv.inner = untag_ptr(arg);
38249         arg_conv.is_owned = ptr_is_owned(arg);
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38251         arg_conv.is_owned = false;
38252         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
38253         return ret_conv;
38254 }
38255
38256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38257         LDKChannelAnnouncement orig_conv;
38258         orig_conv.inner = untag_ptr(orig);
38259         orig_conv.is_owned = ptr_is_owned(orig);
38260         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38261         orig_conv.is_owned = false;
38262         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
38263         int64_t ret_ref = 0;
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38266         return ret_ref;
38267 }
38268
38269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38270         LDKChannelAnnouncement a_conv;
38271         a_conv.inner = untag_ptr(a);
38272         a_conv.is_owned = ptr_is_owned(a);
38273         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38274         a_conv.is_owned = false;
38275         LDKChannelAnnouncement b_conv;
38276         b_conv.inner = untag_ptr(b);
38277         b_conv.is_owned = ptr_is_owned(b);
38278         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38279         b_conv.is_owned = false;
38280         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
38281         return ret_conv;
38282 }
38283
38284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38285         LDKUnsignedChannelUpdate this_obj_conv;
38286         this_obj_conv.inner = untag_ptr(this_obj);
38287         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38289         UnsignedChannelUpdate_free(this_obj_conv);
38290 }
38291
38292 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38293         LDKUnsignedChannelUpdate this_ptr_conv;
38294         this_ptr_conv.inner = untag_ptr(this_ptr);
38295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38297         this_ptr_conv.is_owned = false;
38298         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38299         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
38300         return ret_arr;
38301 }
38302
38303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38304         LDKUnsignedChannelUpdate this_ptr_conv;
38305         this_ptr_conv.inner = untag_ptr(this_ptr);
38306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38308         this_ptr_conv.is_owned = false;
38309         LDKThirtyTwoBytes val_ref;
38310         CHECK((*env)->GetArrayLength(env, val) == 32);
38311         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38312         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
38313 }
38314
38315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38316         LDKUnsignedChannelUpdate this_ptr_conv;
38317         this_ptr_conv.inner = untag_ptr(this_ptr);
38318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38320         this_ptr_conv.is_owned = false;
38321         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
38322         return ret_conv;
38323 }
38324
38325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38326         LDKUnsignedChannelUpdate this_ptr_conv;
38327         this_ptr_conv.inner = untag_ptr(this_ptr);
38328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38330         this_ptr_conv.is_owned = false;
38331         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
38332 }
38333
38334 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38335         LDKUnsignedChannelUpdate this_ptr_conv;
38336         this_ptr_conv.inner = untag_ptr(this_ptr);
38337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38339         this_ptr_conv.is_owned = false;
38340         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
38341         return ret_conv;
38342 }
38343
38344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38345         LDKUnsignedChannelUpdate this_ptr_conv;
38346         this_ptr_conv.inner = untag_ptr(this_ptr);
38347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38349         this_ptr_conv.is_owned = false;
38350         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
38351 }
38352
38353 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
38354         LDKUnsignedChannelUpdate this_ptr_conv;
38355         this_ptr_conv.inner = untag_ptr(this_ptr);
38356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38358         this_ptr_conv.is_owned = false;
38359         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
38360         return ret_conv;
38361 }
38362
38363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
38364         LDKUnsignedChannelUpdate this_ptr_conv;
38365         this_ptr_conv.inner = untag_ptr(this_ptr);
38366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38368         this_ptr_conv.is_owned = false;
38369         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
38370 }
38371
38372 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
38373         LDKUnsignedChannelUpdate this_ptr_conv;
38374         this_ptr_conv.inner = untag_ptr(this_ptr);
38375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38377         this_ptr_conv.is_owned = false;
38378         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
38379         return ret_conv;
38380 }
38381
38382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
38383         LDKUnsignedChannelUpdate this_ptr_conv;
38384         this_ptr_conv.inner = untag_ptr(this_ptr);
38385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38387         this_ptr_conv.is_owned = false;
38388         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
38389 }
38390
38391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38392         LDKUnsignedChannelUpdate this_ptr_conv;
38393         this_ptr_conv.inner = untag_ptr(this_ptr);
38394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38396         this_ptr_conv.is_owned = false;
38397         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
38398         return ret_conv;
38399 }
38400
38401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38402         LDKUnsignedChannelUpdate this_ptr_conv;
38403         this_ptr_conv.inner = untag_ptr(this_ptr);
38404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38406         this_ptr_conv.is_owned = false;
38407         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
38408 }
38409
38410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38411         LDKUnsignedChannelUpdate this_ptr_conv;
38412         this_ptr_conv.inner = untag_ptr(this_ptr);
38413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38415         this_ptr_conv.is_owned = false;
38416         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
38417         return ret_conv;
38418 }
38419
38420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38421         LDKUnsignedChannelUpdate this_ptr_conv;
38422         this_ptr_conv.inner = untag_ptr(this_ptr);
38423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38425         this_ptr_conv.is_owned = false;
38426         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
38427 }
38428
38429 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38430         LDKUnsignedChannelUpdate this_ptr_conv;
38431         this_ptr_conv.inner = untag_ptr(this_ptr);
38432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38434         this_ptr_conv.is_owned = false;
38435         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
38436         return ret_conv;
38437 }
38438
38439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38440         LDKUnsignedChannelUpdate this_ptr_conv;
38441         this_ptr_conv.inner = untag_ptr(this_ptr);
38442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38444         this_ptr_conv.is_owned = false;
38445         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
38446 }
38447
38448 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
38449         LDKUnsignedChannelUpdate this_ptr_conv;
38450         this_ptr_conv.inner = untag_ptr(this_ptr);
38451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38453         this_ptr_conv.is_owned = false;
38454         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
38455         return ret_conv;
38456 }
38457
38458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38459         LDKUnsignedChannelUpdate this_ptr_conv;
38460         this_ptr_conv.inner = untag_ptr(this_ptr);
38461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38463         this_ptr_conv.is_owned = false;
38464         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
38465 }
38466
38467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
38468         LDKUnsignedChannelUpdate this_ptr_conv;
38469         this_ptr_conv.inner = untag_ptr(this_ptr);
38470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38472         this_ptr_conv.is_owned = false;
38473         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
38474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38476         CVec_u8Z_free(ret_var);
38477         return ret_arr;
38478 }
38479
38480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38481         LDKUnsignedChannelUpdate this_ptr_conv;
38482         this_ptr_conv.inner = untag_ptr(this_ptr);
38483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38485         this_ptr_conv.is_owned = false;
38486         LDKCVec_u8Z val_ref;
38487         val_ref.datalen = (*env)->GetArrayLength(env, val);
38488         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38489         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38490         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
38491 }
38492
38493 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) {
38494         LDKThirtyTwoBytes chain_hash_arg_ref;
38495         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38496         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38497         LDKCVec_u8Z excess_data_arg_ref;
38498         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
38499         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
38500         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
38501         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);
38502         int64_t ret_ref = 0;
38503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38505         return ret_ref;
38506 }
38507
38508 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
38509         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
38510         int64_t ret_ref = 0;
38511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38513         return ret_ref;
38514 }
38515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38516         LDKUnsignedChannelUpdate arg_conv;
38517         arg_conv.inner = untag_ptr(arg);
38518         arg_conv.is_owned = ptr_is_owned(arg);
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38520         arg_conv.is_owned = false;
38521         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
38522         return ret_conv;
38523 }
38524
38525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38526         LDKUnsignedChannelUpdate orig_conv;
38527         orig_conv.inner = untag_ptr(orig);
38528         orig_conv.is_owned = ptr_is_owned(orig);
38529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38530         orig_conv.is_owned = false;
38531         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
38532         int64_t ret_ref = 0;
38533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38535         return ret_ref;
38536 }
38537
38538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38539         LDKUnsignedChannelUpdate a_conv;
38540         a_conv.inner = untag_ptr(a);
38541         a_conv.is_owned = ptr_is_owned(a);
38542         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38543         a_conv.is_owned = false;
38544         LDKUnsignedChannelUpdate b_conv;
38545         b_conv.inner = untag_ptr(b);
38546         b_conv.is_owned = ptr_is_owned(b);
38547         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38548         b_conv.is_owned = false;
38549         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
38550         return ret_conv;
38551 }
38552
38553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38554         LDKChannelUpdate this_obj_conv;
38555         this_obj_conv.inner = untag_ptr(this_obj);
38556         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38558         ChannelUpdate_free(this_obj_conv);
38559 }
38560
38561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38562         LDKChannelUpdate this_ptr_conv;
38563         this_ptr_conv.inner = untag_ptr(this_ptr);
38564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38566         this_ptr_conv.is_owned = false;
38567         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
38569         return ret_arr;
38570 }
38571
38572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38573         LDKChannelUpdate this_ptr_conv;
38574         this_ptr_conv.inner = untag_ptr(this_ptr);
38575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38577         this_ptr_conv.is_owned = false;
38578         LDKSignature val_ref;
38579         CHECK((*env)->GetArrayLength(env, val) == 64);
38580         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38581         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
38582 }
38583
38584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38585         LDKChannelUpdate this_ptr_conv;
38586         this_ptr_conv.inner = untag_ptr(this_ptr);
38587         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38589         this_ptr_conv.is_owned = false;
38590         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
38591         int64_t ret_ref = 0;
38592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38593         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38594         return ret_ref;
38595 }
38596
38597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38598         LDKChannelUpdate this_ptr_conv;
38599         this_ptr_conv.inner = untag_ptr(this_ptr);
38600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38602         this_ptr_conv.is_owned = false;
38603         LDKUnsignedChannelUpdate val_conv;
38604         val_conv.inner = untag_ptr(val);
38605         val_conv.is_owned = ptr_is_owned(val);
38606         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38607         val_conv = UnsignedChannelUpdate_clone(&val_conv);
38608         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
38609 }
38610
38611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
38612         LDKSignature signature_arg_ref;
38613         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
38614         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
38615         LDKUnsignedChannelUpdate contents_arg_conv;
38616         contents_arg_conv.inner = untag_ptr(contents_arg);
38617         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38618         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38619         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
38620         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
38621         int64_t ret_ref = 0;
38622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38623         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38624         return ret_ref;
38625 }
38626
38627 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
38628         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
38629         int64_t ret_ref = 0;
38630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38632         return ret_ref;
38633 }
38634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38635         LDKChannelUpdate arg_conv;
38636         arg_conv.inner = untag_ptr(arg);
38637         arg_conv.is_owned = ptr_is_owned(arg);
38638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38639         arg_conv.is_owned = false;
38640         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
38641         return ret_conv;
38642 }
38643
38644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38645         LDKChannelUpdate orig_conv;
38646         orig_conv.inner = untag_ptr(orig);
38647         orig_conv.is_owned = ptr_is_owned(orig);
38648         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38649         orig_conv.is_owned = false;
38650         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
38651         int64_t ret_ref = 0;
38652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38654         return ret_ref;
38655 }
38656
38657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38658         LDKChannelUpdate a_conv;
38659         a_conv.inner = untag_ptr(a);
38660         a_conv.is_owned = ptr_is_owned(a);
38661         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38662         a_conv.is_owned = false;
38663         LDKChannelUpdate b_conv;
38664         b_conv.inner = untag_ptr(b);
38665         b_conv.is_owned = ptr_is_owned(b);
38666         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38667         b_conv.is_owned = false;
38668         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
38669         return ret_conv;
38670 }
38671
38672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38673         LDKQueryChannelRange this_obj_conv;
38674         this_obj_conv.inner = untag_ptr(this_obj);
38675         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38677         QueryChannelRange_free(this_obj_conv);
38678 }
38679
38680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38681         LDKQueryChannelRange this_ptr_conv;
38682         this_ptr_conv.inner = untag_ptr(this_ptr);
38683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38685         this_ptr_conv.is_owned = false;
38686         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
38688         return ret_arr;
38689 }
38690
38691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38692         LDKQueryChannelRange this_ptr_conv;
38693         this_ptr_conv.inner = untag_ptr(this_ptr);
38694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38696         this_ptr_conv.is_owned = false;
38697         LDKThirtyTwoBytes val_ref;
38698         CHECK((*env)->GetArrayLength(env, val) == 32);
38699         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38700         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
38701 }
38702
38703 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
38704         LDKQueryChannelRange this_ptr_conv;
38705         this_ptr_conv.inner = untag_ptr(this_ptr);
38706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38708         this_ptr_conv.is_owned = false;
38709         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
38710         return ret_conv;
38711 }
38712
38713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38714         LDKQueryChannelRange this_ptr_conv;
38715         this_ptr_conv.inner = untag_ptr(this_ptr);
38716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38718         this_ptr_conv.is_owned = false;
38719         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
38720 }
38721
38722 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
38723         LDKQueryChannelRange this_ptr_conv;
38724         this_ptr_conv.inner = untag_ptr(this_ptr);
38725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38727         this_ptr_conv.is_owned = false;
38728         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
38729         return ret_conv;
38730 }
38731
38732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38733         LDKQueryChannelRange this_ptr_conv;
38734         this_ptr_conv.inner = untag_ptr(this_ptr);
38735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38737         this_ptr_conv.is_owned = false;
38738         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
38739 }
38740
38741 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) {
38742         LDKThirtyTwoBytes chain_hash_arg_ref;
38743         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38744         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38745         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
38746         int64_t ret_ref = 0;
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38749         return ret_ref;
38750 }
38751
38752 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
38753         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
38754         int64_t ret_ref = 0;
38755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38757         return ret_ref;
38758 }
38759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38760         LDKQueryChannelRange arg_conv;
38761         arg_conv.inner = untag_ptr(arg);
38762         arg_conv.is_owned = ptr_is_owned(arg);
38763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38764         arg_conv.is_owned = false;
38765         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
38766         return ret_conv;
38767 }
38768
38769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38770         LDKQueryChannelRange orig_conv;
38771         orig_conv.inner = untag_ptr(orig);
38772         orig_conv.is_owned = ptr_is_owned(orig);
38773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38774         orig_conv.is_owned = false;
38775         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
38776         int64_t ret_ref = 0;
38777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38779         return ret_ref;
38780 }
38781
38782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38783         LDKQueryChannelRange a_conv;
38784         a_conv.inner = untag_ptr(a);
38785         a_conv.is_owned = ptr_is_owned(a);
38786         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38787         a_conv.is_owned = false;
38788         LDKQueryChannelRange b_conv;
38789         b_conv.inner = untag_ptr(b);
38790         b_conv.is_owned = ptr_is_owned(b);
38791         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38792         b_conv.is_owned = false;
38793         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
38794         return ret_conv;
38795 }
38796
38797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38798         LDKReplyChannelRange this_obj_conv;
38799         this_obj_conv.inner = untag_ptr(this_obj);
38800         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38802         ReplyChannelRange_free(this_obj_conv);
38803 }
38804
38805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38806         LDKReplyChannelRange this_ptr_conv;
38807         this_ptr_conv.inner = untag_ptr(this_ptr);
38808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38810         this_ptr_conv.is_owned = false;
38811         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
38813         return ret_arr;
38814 }
38815
38816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38817         LDKReplyChannelRange this_ptr_conv;
38818         this_ptr_conv.inner = untag_ptr(this_ptr);
38819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38821         this_ptr_conv.is_owned = false;
38822         LDKThirtyTwoBytes val_ref;
38823         CHECK((*env)->GetArrayLength(env, val) == 32);
38824         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38825         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
38826 }
38827
38828 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
38829         LDKReplyChannelRange this_ptr_conv;
38830         this_ptr_conv.inner = untag_ptr(this_ptr);
38831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38833         this_ptr_conv.is_owned = false;
38834         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
38835         return ret_conv;
38836 }
38837
38838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38839         LDKReplyChannelRange this_ptr_conv;
38840         this_ptr_conv.inner = untag_ptr(this_ptr);
38841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38843         this_ptr_conv.is_owned = false;
38844         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
38845 }
38846
38847 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
38848         LDKReplyChannelRange this_ptr_conv;
38849         this_ptr_conv.inner = untag_ptr(this_ptr);
38850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38852         this_ptr_conv.is_owned = false;
38853         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
38854         return ret_conv;
38855 }
38856
38857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38858         LDKReplyChannelRange this_ptr_conv;
38859         this_ptr_conv.inner = untag_ptr(this_ptr);
38860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38862         this_ptr_conv.is_owned = false;
38863         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
38864 }
38865
38866 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
38867         LDKReplyChannelRange this_ptr_conv;
38868         this_ptr_conv.inner = untag_ptr(this_ptr);
38869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38871         this_ptr_conv.is_owned = false;
38872         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
38873         return ret_conv;
38874 }
38875
38876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38877         LDKReplyChannelRange this_ptr_conv;
38878         this_ptr_conv.inner = untag_ptr(this_ptr);
38879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38881         this_ptr_conv.is_owned = false;
38882         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
38883 }
38884
38885 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
38886         LDKReplyChannelRange this_ptr_conv;
38887         this_ptr_conv.inner = untag_ptr(this_ptr);
38888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38890         this_ptr_conv.is_owned = false;
38891         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
38892         int64_tArray ret_arr = NULL;
38893         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38894         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38895         for (size_t g = 0; g < ret_var.datalen; g++) {
38896                 int64_t ret_conv_6_conv = ret_var.data[g];
38897                 ret_arr_ptr[g] = ret_conv_6_conv;
38898         }
38899         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38900         FREE(ret_var.data);
38901         return ret_arr;
38902 }
38903
38904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38905         LDKReplyChannelRange this_ptr_conv;
38906         this_ptr_conv.inner = untag_ptr(this_ptr);
38907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38909         this_ptr_conv.is_owned = false;
38910         LDKCVec_u64Z val_constr;
38911         val_constr.datalen = (*env)->GetArrayLength(env, val);
38912         if (val_constr.datalen > 0)
38913                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38914         else
38915                 val_constr.data = NULL;
38916         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38917         for (size_t g = 0; g < val_constr.datalen; g++) {
38918                 int64_t val_conv_6 = val_vals[g];
38919                 val_constr.data[g] = val_conv_6;
38920         }
38921         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38922         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
38923 }
38924
38925 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) {
38926         LDKThirtyTwoBytes chain_hash_arg_ref;
38927         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38928         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38929         LDKCVec_u64Z short_channel_ids_arg_constr;
38930         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
38931         if (short_channel_ids_arg_constr.datalen > 0)
38932                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38933         else
38934                 short_channel_ids_arg_constr.data = NULL;
38935         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
38936         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
38937                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
38938                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
38939         }
38940         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
38941         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
38942         int64_t ret_ref = 0;
38943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38945         return ret_ref;
38946 }
38947
38948 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
38949         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
38950         int64_t ret_ref = 0;
38951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38953         return ret_ref;
38954 }
38955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38956         LDKReplyChannelRange arg_conv;
38957         arg_conv.inner = untag_ptr(arg);
38958         arg_conv.is_owned = ptr_is_owned(arg);
38959         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38960         arg_conv.is_owned = false;
38961         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
38962         return ret_conv;
38963 }
38964
38965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38966         LDKReplyChannelRange orig_conv;
38967         orig_conv.inner = untag_ptr(orig);
38968         orig_conv.is_owned = ptr_is_owned(orig);
38969         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38970         orig_conv.is_owned = false;
38971         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
38972         int64_t ret_ref = 0;
38973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38975         return ret_ref;
38976 }
38977
38978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38979         LDKReplyChannelRange a_conv;
38980         a_conv.inner = untag_ptr(a);
38981         a_conv.is_owned = ptr_is_owned(a);
38982         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38983         a_conv.is_owned = false;
38984         LDKReplyChannelRange b_conv;
38985         b_conv.inner = untag_ptr(b);
38986         b_conv.is_owned = ptr_is_owned(b);
38987         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38988         b_conv.is_owned = false;
38989         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
38990         return ret_conv;
38991 }
38992
38993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38994         LDKQueryShortChannelIds this_obj_conv;
38995         this_obj_conv.inner = untag_ptr(this_obj);
38996         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38998         QueryShortChannelIds_free(this_obj_conv);
38999 }
39000
39001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39002         LDKQueryShortChannelIds this_ptr_conv;
39003         this_ptr_conv.inner = untag_ptr(this_ptr);
39004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39006         this_ptr_conv.is_owned = false;
39007         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39008         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
39009         return ret_arr;
39010 }
39011
39012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39013         LDKQueryShortChannelIds this_ptr_conv;
39014         this_ptr_conv.inner = untag_ptr(this_ptr);
39015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39017         this_ptr_conv.is_owned = false;
39018         LDKThirtyTwoBytes val_ref;
39019         CHECK((*env)->GetArrayLength(env, val) == 32);
39020         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39021         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
39022 }
39023
39024 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39025         LDKQueryShortChannelIds this_ptr_conv;
39026         this_ptr_conv.inner = untag_ptr(this_ptr);
39027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39029         this_ptr_conv.is_owned = false;
39030         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
39031         int64_tArray ret_arr = NULL;
39032         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39033         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39034         for (size_t g = 0; g < ret_var.datalen; g++) {
39035                 int64_t ret_conv_6_conv = ret_var.data[g];
39036                 ret_arr_ptr[g] = ret_conv_6_conv;
39037         }
39038         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39039         FREE(ret_var.data);
39040         return ret_arr;
39041 }
39042
39043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39044         LDKQueryShortChannelIds this_ptr_conv;
39045         this_ptr_conv.inner = untag_ptr(this_ptr);
39046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39048         this_ptr_conv.is_owned = false;
39049         LDKCVec_u64Z val_constr;
39050         val_constr.datalen = (*env)->GetArrayLength(env, val);
39051         if (val_constr.datalen > 0)
39052                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39053         else
39054                 val_constr.data = NULL;
39055         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39056         for (size_t g = 0; g < val_constr.datalen; g++) {
39057                 int64_t val_conv_6 = val_vals[g];
39058                 val_constr.data[g] = val_conv_6;
39059         }
39060         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39061         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
39062 }
39063
39064 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) {
39065         LDKThirtyTwoBytes chain_hash_arg_ref;
39066         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39067         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39068         LDKCVec_u64Z short_channel_ids_arg_constr;
39069         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39070         if (short_channel_ids_arg_constr.datalen > 0)
39071                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39072         else
39073                 short_channel_ids_arg_constr.data = NULL;
39074         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39075         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39076                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39077                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39078         }
39079         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39080         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
39081         int64_t ret_ref = 0;
39082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39084         return ret_ref;
39085 }
39086
39087 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
39088         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
39089         int64_t ret_ref = 0;
39090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39091         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39092         return ret_ref;
39093 }
39094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39095         LDKQueryShortChannelIds arg_conv;
39096         arg_conv.inner = untag_ptr(arg);
39097         arg_conv.is_owned = ptr_is_owned(arg);
39098         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39099         arg_conv.is_owned = false;
39100         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
39101         return ret_conv;
39102 }
39103
39104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39105         LDKQueryShortChannelIds orig_conv;
39106         orig_conv.inner = untag_ptr(orig);
39107         orig_conv.is_owned = ptr_is_owned(orig);
39108         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39109         orig_conv.is_owned = false;
39110         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
39111         int64_t ret_ref = 0;
39112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39114         return ret_ref;
39115 }
39116
39117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39118         LDKQueryShortChannelIds a_conv;
39119         a_conv.inner = untag_ptr(a);
39120         a_conv.is_owned = ptr_is_owned(a);
39121         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39122         a_conv.is_owned = false;
39123         LDKQueryShortChannelIds b_conv;
39124         b_conv.inner = untag_ptr(b);
39125         b_conv.is_owned = ptr_is_owned(b);
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39127         b_conv.is_owned = false;
39128         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
39129         return ret_conv;
39130 }
39131
39132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39133         LDKReplyShortChannelIdsEnd this_obj_conv;
39134         this_obj_conv.inner = untag_ptr(this_obj);
39135         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39137         ReplyShortChannelIdsEnd_free(this_obj_conv);
39138 }
39139
39140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39141         LDKReplyShortChannelIdsEnd this_ptr_conv;
39142         this_ptr_conv.inner = untag_ptr(this_ptr);
39143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39145         this_ptr_conv.is_owned = false;
39146         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
39148         return ret_arr;
39149 }
39150
39151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39152         LDKReplyShortChannelIdsEnd this_ptr_conv;
39153         this_ptr_conv.inner = untag_ptr(this_ptr);
39154         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39156         this_ptr_conv.is_owned = false;
39157         LDKThirtyTwoBytes val_ref;
39158         CHECK((*env)->GetArrayLength(env, val) == 32);
39159         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39160         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
39161 }
39162
39163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
39164         LDKReplyShortChannelIdsEnd this_ptr_conv;
39165         this_ptr_conv.inner = untag_ptr(this_ptr);
39166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39168         this_ptr_conv.is_owned = false;
39169         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
39170         return ret_conv;
39171 }
39172
39173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39174         LDKReplyShortChannelIdsEnd this_ptr_conv;
39175         this_ptr_conv.inner = untag_ptr(this_ptr);
39176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39178         this_ptr_conv.is_owned = false;
39179         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
39180 }
39181
39182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
39183         LDKThirtyTwoBytes chain_hash_arg_ref;
39184         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39185         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39186         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
39187         int64_t ret_ref = 0;
39188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39190         return ret_ref;
39191 }
39192
39193 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
39194         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
39195         int64_t ret_ref = 0;
39196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39198         return ret_ref;
39199 }
39200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39201         LDKReplyShortChannelIdsEnd arg_conv;
39202         arg_conv.inner = untag_ptr(arg);
39203         arg_conv.is_owned = ptr_is_owned(arg);
39204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39205         arg_conv.is_owned = false;
39206         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
39207         return ret_conv;
39208 }
39209
39210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39211         LDKReplyShortChannelIdsEnd orig_conv;
39212         orig_conv.inner = untag_ptr(orig);
39213         orig_conv.is_owned = ptr_is_owned(orig);
39214         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39215         orig_conv.is_owned = false;
39216         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
39217         int64_t ret_ref = 0;
39218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39219         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39220         return ret_ref;
39221 }
39222
39223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39224         LDKReplyShortChannelIdsEnd a_conv;
39225         a_conv.inner = untag_ptr(a);
39226         a_conv.is_owned = ptr_is_owned(a);
39227         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39228         a_conv.is_owned = false;
39229         LDKReplyShortChannelIdsEnd b_conv;
39230         b_conv.inner = untag_ptr(b);
39231         b_conv.is_owned = ptr_is_owned(b);
39232         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39233         b_conv.is_owned = false;
39234         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
39235         return ret_conv;
39236 }
39237
39238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39239         LDKGossipTimestampFilter this_obj_conv;
39240         this_obj_conv.inner = untag_ptr(this_obj);
39241         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39243         GossipTimestampFilter_free(this_obj_conv);
39244 }
39245
39246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39247         LDKGossipTimestampFilter this_ptr_conv;
39248         this_ptr_conv.inner = untag_ptr(this_ptr);
39249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39251         this_ptr_conv.is_owned = false;
39252         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
39254         return ret_arr;
39255 }
39256
39257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39258         LDKGossipTimestampFilter this_ptr_conv;
39259         this_ptr_conv.inner = untag_ptr(this_ptr);
39260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39262         this_ptr_conv.is_owned = false;
39263         LDKThirtyTwoBytes val_ref;
39264         CHECK((*env)->GetArrayLength(env, val) == 32);
39265         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39266         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
39267 }
39268
39269 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39270         LDKGossipTimestampFilter this_ptr_conv;
39271         this_ptr_conv.inner = untag_ptr(this_ptr);
39272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39274         this_ptr_conv.is_owned = false;
39275         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
39276         return ret_conv;
39277 }
39278
39279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39280         LDKGossipTimestampFilter this_ptr_conv;
39281         this_ptr_conv.inner = untag_ptr(this_ptr);
39282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39284         this_ptr_conv.is_owned = false;
39285         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
39286 }
39287
39288 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
39289         LDKGossipTimestampFilter this_ptr_conv;
39290         this_ptr_conv.inner = untag_ptr(this_ptr);
39291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39293         this_ptr_conv.is_owned = false;
39294         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
39295         return ret_conv;
39296 }
39297
39298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39299         LDKGossipTimestampFilter this_ptr_conv;
39300         this_ptr_conv.inner = untag_ptr(this_ptr);
39301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39303         this_ptr_conv.is_owned = false;
39304         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
39305 }
39306
39307 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) {
39308         LDKThirtyTwoBytes chain_hash_arg_ref;
39309         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39310         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39311         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
39312         int64_t ret_ref = 0;
39313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39315         return ret_ref;
39316 }
39317
39318 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
39319         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
39320         int64_t ret_ref = 0;
39321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39322         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39323         return ret_ref;
39324 }
39325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39326         LDKGossipTimestampFilter arg_conv;
39327         arg_conv.inner = untag_ptr(arg);
39328         arg_conv.is_owned = ptr_is_owned(arg);
39329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39330         arg_conv.is_owned = false;
39331         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
39332         return ret_conv;
39333 }
39334
39335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39336         LDKGossipTimestampFilter orig_conv;
39337         orig_conv.inner = untag_ptr(orig);
39338         orig_conv.is_owned = ptr_is_owned(orig);
39339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39340         orig_conv.is_owned = false;
39341         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
39342         int64_t ret_ref = 0;
39343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39344         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39345         return ret_ref;
39346 }
39347
39348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39349         LDKGossipTimestampFilter a_conv;
39350         a_conv.inner = untag_ptr(a);
39351         a_conv.is_owned = ptr_is_owned(a);
39352         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39353         a_conv.is_owned = false;
39354         LDKGossipTimestampFilter b_conv;
39355         b_conv.inner = untag_ptr(b);
39356         b_conv.is_owned = ptr_is_owned(b);
39357         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39358         b_conv.is_owned = false;
39359         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
39360         return ret_conv;
39361 }
39362
39363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39364         if (!ptr_is_owned(this_ptr)) return;
39365         void* this_ptr_ptr = untag_ptr(this_ptr);
39366         CHECK_ACCESS(this_ptr_ptr);
39367         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
39368         FREE(untag_ptr(this_ptr));
39369         ErrorAction_free(this_ptr_conv);
39370 }
39371
39372 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
39373         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39374         *ret_copy = ErrorAction_clone(arg);
39375         int64_t ret_ref = tag_ptr(ret_copy, true);
39376         return ret_ref;
39377 }
39378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39379         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
39380         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
39381         return ret_conv;
39382 }
39383
39384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39385         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
39386         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39387         *ret_copy = ErrorAction_clone(orig_conv);
39388         int64_t ret_ref = tag_ptr(ret_copy, true);
39389         return ret_ref;
39390 }
39391
39392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
39393         LDKErrorMessage msg_conv;
39394         msg_conv.inner = untag_ptr(msg);
39395         msg_conv.is_owned = ptr_is_owned(msg);
39396         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39397         msg_conv = ErrorMessage_clone(&msg_conv);
39398         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39399         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
39400         int64_t ret_ref = tag_ptr(ret_copy, true);
39401         return ret_ref;
39402 }
39403
39404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
39405         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39406         *ret_copy = ErrorAction_ignore_error();
39407         int64_t ret_ref = tag_ptr(ret_copy, true);
39408         return ret_ref;
39409 }
39410
39411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
39412         LDKLevel a_conv = LDKLevel_from_java(env, a);
39413         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39414         *ret_copy = ErrorAction_ignore_and_log(a_conv);
39415         int64_t ret_ref = tag_ptr(ret_copy, true);
39416         return ret_ref;
39417 }
39418
39419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
39420         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39421         *ret_copy = ErrorAction_ignore_duplicate_gossip();
39422         int64_t ret_ref = tag_ptr(ret_copy, true);
39423         return ret_ref;
39424 }
39425
39426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
39427         LDKErrorMessage msg_conv;
39428         msg_conv.inner = untag_ptr(msg);
39429         msg_conv.is_owned = ptr_is_owned(msg);
39430         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39431         msg_conv = ErrorMessage_clone(&msg_conv);
39432         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39433         *ret_copy = ErrorAction_send_error_message(msg_conv);
39434         int64_t ret_ref = tag_ptr(ret_copy, true);
39435         return ret_ref;
39436 }
39437
39438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
39439         LDKWarningMessage msg_conv;
39440         msg_conv.inner = untag_ptr(msg);
39441         msg_conv.is_owned = ptr_is_owned(msg);
39442         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39443         msg_conv = WarningMessage_clone(&msg_conv);
39444         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
39445         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39446         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
39447         int64_t ret_ref = tag_ptr(ret_copy, true);
39448         return ret_ref;
39449 }
39450
39451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39452         LDKLightningError this_obj_conv;
39453         this_obj_conv.inner = untag_ptr(this_obj);
39454         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39456         LightningError_free(this_obj_conv);
39457 }
39458
39459 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
39460         LDKLightningError this_ptr_conv;
39461         this_ptr_conv.inner = untag_ptr(this_ptr);
39462         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39464         this_ptr_conv.is_owned = false;
39465         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
39466         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39467         Str_free(ret_str);
39468         return ret_conv;
39469 }
39470
39471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
39472         LDKLightningError this_ptr_conv;
39473         this_ptr_conv.inner = untag_ptr(this_ptr);
39474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39476         this_ptr_conv.is_owned = false;
39477         LDKStr val_conv = java_to_owned_str(env, val);
39478         LightningError_set_err(&this_ptr_conv, val_conv);
39479 }
39480
39481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
39482         LDKLightningError this_ptr_conv;
39483         this_ptr_conv.inner = untag_ptr(this_ptr);
39484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39486         this_ptr_conv.is_owned = false;
39487         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39488         *ret_copy = LightningError_get_action(&this_ptr_conv);
39489         int64_t ret_ref = tag_ptr(ret_copy, true);
39490         return ret_ref;
39491 }
39492
39493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39494         LDKLightningError this_ptr_conv;
39495         this_ptr_conv.inner = untag_ptr(this_ptr);
39496         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39498         this_ptr_conv.is_owned = false;
39499         void* val_ptr = untag_ptr(val);
39500         CHECK_ACCESS(val_ptr);
39501         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
39502         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
39503         LightningError_set_action(&this_ptr_conv, val_conv);
39504 }
39505
39506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
39507         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
39508         void* action_arg_ptr = untag_ptr(action_arg);
39509         CHECK_ACCESS(action_arg_ptr);
39510         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
39511         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
39512         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
39513         int64_t ret_ref = 0;
39514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39516         return ret_ref;
39517 }
39518
39519 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
39520         LDKLightningError ret_var = LightningError_clone(arg);
39521         int64_t ret_ref = 0;
39522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39523         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39524         return ret_ref;
39525 }
39526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39527         LDKLightningError arg_conv;
39528         arg_conv.inner = untag_ptr(arg);
39529         arg_conv.is_owned = ptr_is_owned(arg);
39530         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39531         arg_conv.is_owned = false;
39532         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
39533         return ret_conv;
39534 }
39535
39536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39537         LDKLightningError orig_conv;
39538         orig_conv.inner = untag_ptr(orig);
39539         orig_conv.is_owned = ptr_is_owned(orig);
39540         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39541         orig_conv.is_owned = false;
39542         LDKLightningError ret_var = LightningError_clone(&orig_conv);
39543         int64_t ret_ref = 0;
39544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39545         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39546         return ret_ref;
39547 }
39548
39549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39550         LDKCommitmentUpdate this_obj_conv;
39551         this_obj_conv.inner = untag_ptr(this_obj);
39552         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39554         CommitmentUpdate_free(this_obj_conv);
39555 }
39556
39557 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39558         LDKCommitmentUpdate this_ptr_conv;
39559         this_ptr_conv.inner = untag_ptr(this_ptr);
39560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39562         this_ptr_conv.is_owned = false;
39563         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
39564         int64_tArray ret_arr = NULL;
39565         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39566         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39567         for (size_t p = 0; p < ret_var.datalen; p++) {
39568                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
39569                 int64_t ret_conv_15_ref = 0;
39570                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
39571                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
39572                 ret_arr_ptr[p] = ret_conv_15_ref;
39573         }
39574         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39575         FREE(ret_var.data);
39576         return ret_arr;
39577 }
39578
39579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39580         LDKCommitmentUpdate this_ptr_conv;
39581         this_ptr_conv.inner = untag_ptr(this_ptr);
39582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39584         this_ptr_conv.is_owned = false;
39585         LDKCVec_UpdateAddHTLCZ val_constr;
39586         val_constr.datalen = (*env)->GetArrayLength(env, val);
39587         if (val_constr.datalen > 0)
39588                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
39589         else
39590                 val_constr.data = NULL;
39591         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39592         for (size_t p = 0; p < val_constr.datalen; p++) {
39593                 int64_t val_conv_15 = val_vals[p];
39594                 LDKUpdateAddHTLC val_conv_15_conv;
39595                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
39596                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
39597                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
39598                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
39599                 val_constr.data[p] = val_conv_15_conv;
39600         }
39601         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39602         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
39603 }
39604
39605 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39606         LDKCommitmentUpdate this_ptr_conv;
39607         this_ptr_conv.inner = untag_ptr(this_ptr);
39608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39610         this_ptr_conv.is_owned = false;
39611         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
39612         int64_tArray ret_arr = NULL;
39613         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39614         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39615         for (size_t t = 0; t < ret_var.datalen; t++) {
39616                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
39617                 int64_t ret_conv_19_ref = 0;
39618                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
39619                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
39620                 ret_arr_ptr[t] = ret_conv_19_ref;
39621         }
39622         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39623         FREE(ret_var.data);
39624         return ret_arr;
39625 }
39626
39627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39628         LDKCommitmentUpdate this_ptr_conv;
39629         this_ptr_conv.inner = untag_ptr(this_ptr);
39630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39632         this_ptr_conv.is_owned = false;
39633         LDKCVec_UpdateFulfillHTLCZ val_constr;
39634         val_constr.datalen = (*env)->GetArrayLength(env, val);
39635         if (val_constr.datalen > 0)
39636                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
39637         else
39638                 val_constr.data = NULL;
39639         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39640         for (size_t t = 0; t < val_constr.datalen; t++) {
39641                 int64_t val_conv_19 = val_vals[t];
39642                 LDKUpdateFulfillHTLC val_conv_19_conv;
39643                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
39644                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
39645                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
39646                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
39647                 val_constr.data[t] = val_conv_19_conv;
39648         }
39649         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39650         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
39651 }
39652
39653 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39654         LDKCommitmentUpdate this_ptr_conv;
39655         this_ptr_conv.inner = untag_ptr(this_ptr);
39656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39658         this_ptr_conv.is_owned = false;
39659         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
39660         int64_tArray ret_arr = NULL;
39661         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39662         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39663         for (size_t q = 0; q < ret_var.datalen; q++) {
39664                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
39665                 int64_t ret_conv_16_ref = 0;
39666                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
39667                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
39668                 ret_arr_ptr[q] = ret_conv_16_ref;
39669         }
39670         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39671         FREE(ret_var.data);
39672         return ret_arr;
39673 }
39674
39675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39676         LDKCommitmentUpdate this_ptr_conv;
39677         this_ptr_conv.inner = untag_ptr(this_ptr);
39678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39680         this_ptr_conv.is_owned = false;
39681         LDKCVec_UpdateFailHTLCZ val_constr;
39682         val_constr.datalen = (*env)->GetArrayLength(env, val);
39683         if (val_constr.datalen > 0)
39684                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
39685         else
39686                 val_constr.data = NULL;
39687         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39688         for (size_t q = 0; q < val_constr.datalen; q++) {
39689                 int64_t val_conv_16 = val_vals[q];
39690                 LDKUpdateFailHTLC val_conv_16_conv;
39691                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
39692                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
39693                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
39694                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
39695                 val_constr.data[q] = val_conv_16_conv;
39696         }
39697         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39698         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
39699 }
39700
39701 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39702         LDKCommitmentUpdate this_ptr_conv;
39703         this_ptr_conv.inner = untag_ptr(this_ptr);
39704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39706         this_ptr_conv.is_owned = false;
39707         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
39708         int64_tArray ret_arr = NULL;
39709         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39710         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39711         for (size_t z = 0; z < ret_var.datalen; z++) {
39712                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
39713                 int64_t ret_conv_25_ref = 0;
39714                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
39715                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
39716                 ret_arr_ptr[z] = ret_conv_25_ref;
39717         }
39718         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39719         FREE(ret_var.data);
39720         return ret_arr;
39721 }
39722
39723 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) {
39724         LDKCommitmentUpdate this_ptr_conv;
39725         this_ptr_conv.inner = untag_ptr(this_ptr);
39726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39728         this_ptr_conv.is_owned = false;
39729         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
39730         val_constr.datalen = (*env)->GetArrayLength(env, val);
39731         if (val_constr.datalen > 0)
39732                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
39733         else
39734                 val_constr.data = NULL;
39735         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39736         for (size_t z = 0; z < val_constr.datalen; z++) {
39737                 int64_t val_conv_25 = val_vals[z];
39738                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
39739                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
39740                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
39741                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
39742                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
39743                 val_constr.data[z] = val_conv_25_conv;
39744         }
39745         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39746         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
39747 }
39748
39749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
39750         LDKCommitmentUpdate this_ptr_conv;
39751         this_ptr_conv.inner = untag_ptr(this_ptr);
39752         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39754         this_ptr_conv.is_owned = false;
39755         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
39756         int64_t ret_ref = 0;
39757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39759         return ret_ref;
39760 }
39761
39762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39763         LDKCommitmentUpdate this_ptr_conv;
39764         this_ptr_conv.inner = untag_ptr(this_ptr);
39765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39767         this_ptr_conv.is_owned = false;
39768         LDKUpdateFee val_conv;
39769         val_conv.inner = untag_ptr(val);
39770         val_conv.is_owned = ptr_is_owned(val);
39771         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39772         val_conv = UpdateFee_clone(&val_conv);
39773         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
39774 }
39775
39776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
39777         LDKCommitmentUpdate this_ptr_conv;
39778         this_ptr_conv.inner = untag_ptr(this_ptr);
39779         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39781         this_ptr_conv.is_owned = false;
39782         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
39783         int64_t ret_ref = 0;
39784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39786         return ret_ref;
39787 }
39788
39789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39790         LDKCommitmentUpdate this_ptr_conv;
39791         this_ptr_conv.inner = untag_ptr(this_ptr);
39792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39794         this_ptr_conv.is_owned = false;
39795         LDKCommitmentSigned val_conv;
39796         val_conv.inner = untag_ptr(val);
39797         val_conv.is_owned = ptr_is_owned(val);
39798         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39799         val_conv = CommitmentSigned_clone(&val_conv);
39800         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
39801 }
39802
39803 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) {
39804         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
39805         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
39806         if (update_add_htlcs_arg_constr.datalen > 0)
39807                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
39808         else
39809                 update_add_htlcs_arg_constr.data = NULL;
39810         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
39811         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
39812                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
39813                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
39814                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
39815                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
39816                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
39817                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
39818                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
39819         }
39820         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
39821         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
39822         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
39823         if (update_fulfill_htlcs_arg_constr.datalen > 0)
39824                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
39825         else
39826                 update_fulfill_htlcs_arg_constr.data = NULL;
39827         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
39828         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
39829                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
39830                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
39831                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
39832                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
39833                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
39834                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
39835                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
39836         }
39837         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
39838         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
39839         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
39840         if (update_fail_htlcs_arg_constr.datalen > 0)
39841                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
39842         else
39843                 update_fail_htlcs_arg_constr.data = NULL;
39844         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
39845         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
39846                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
39847                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
39848                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
39849                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
39850                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
39851                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
39852                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
39853         }
39854         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
39855         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
39856         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
39857         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
39858                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
39859         else
39860                 update_fail_malformed_htlcs_arg_constr.data = NULL;
39861         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
39862         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
39863                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
39864                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
39865                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
39866                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
39867                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
39868                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
39869                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
39870         }
39871         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
39872         LDKUpdateFee update_fee_arg_conv;
39873         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
39874         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
39875         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
39876         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
39877         LDKCommitmentSigned commitment_signed_arg_conv;
39878         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
39879         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
39880         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
39881         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
39882         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);
39883         int64_t ret_ref = 0;
39884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39886         return ret_ref;
39887 }
39888
39889 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
39890         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
39891         int64_t ret_ref = 0;
39892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39893         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39894         return ret_ref;
39895 }
39896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39897         LDKCommitmentUpdate arg_conv;
39898         arg_conv.inner = untag_ptr(arg);
39899         arg_conv.is_owned = ptr_is_owned(arg);
39900         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39901         arg_conv.is_owned = false;
39902         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
39903         return ret_conv;
39904 }
39905
39906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39907         LDKCommitmentUpdate orig_conv;
39908         orig_conv.inner = untag_ptr(orig);
39909         orig_conv.is_owned = ptr_is_owned(orig);
39910         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39911         orig_conv.is_owned = false;
39912         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
39913         int64_t ret_ref = 0;
39914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39916         return ret_ref;
39917 }
39918
39919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39920         LDKCommitmentUpdate a_conv;
39921         a_conv.inner = untag_ptr(a);
39922         a_conv.is_owned = ptr_is_owned(a);
39923         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39924         a_conv.is_owned = false;
39925         LDKCommitmentUpdate b_conv;
39926         b_conv.inner = untag_ptr(b);
39927         b_conv.is_owned = ptr_is_owned(b);
39928         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39929         b_conv.is_owned = false;
39930         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
39931         return ret_conv;
39932 }
39933
39934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39935         if (!ptr_is_owned(this_ptr)) return;
39936         void* this_ptr_ptr = untag_ptr(this_ptr);
39937         CHECK_ACCESS(this_ptr_ptr);
39938         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
39939         FREE(untag_ptr(this_ptr));
39940         ChannelMessageHandler_free(this_ptr_conv);
39941 }
39942
39943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39944         if (!ptr_is_owned(this_ptr)) return;
39945         void* this_ptr_ptr = untag_ptr(this_ptr);
39946         CHECK_ACCESS(this_ptr_ptr);
39947         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
39948         FREE(untag_ptr(this_ptr));
39949         RoutingMessageHandler_free(this_ptr_conv);
39950 }
39951
39952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39953         if (!ptr_is_owned(this_ptr)) return;
39954         void* this_ptr_ptr = untag_ptr(this_ptr);
39955         CHECK_ACCESS(this_ptr_ptr);
39956         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
39957         FREE(untag_ptr(this_ptr));
39958         OnionMessageHandler_free(this_ptr_conv);
39959 }
39960
39961 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
39962         LDKAcceptChannel obj_conv;
39963         obj_conv.inner = untag_ptr(obj);
39964         obj_conv.is_owned = ptr_is_owned(obj);
39965         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39966         obj_conv.is_owned = false;
39967         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
39968         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39969         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39970         CVec_u8Z_free(ret_var);
39971         return ret_arr;
39972 }
39973
39974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39975         LDKu8slice ser_ref;
39976         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39977         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39978         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
39979         *ret_conv = AcceptChannel_read(ser_ref);
39980         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39981         return tag_ptr(ret_conv, true);
39982 }
39983
39984 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39985         LDKAnnouncementSignatures obj_conv;
39986         obj_conv.inner = untag_ptr(obj);
39987         obj_conv.is_owned = ptr_is_owned(obj);
39988         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39989         obj_conv.is_owned = false;
39990         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
39991         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39992         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39993         CVec_u8Z_free(ret_var);
39994         return ret_arr;
39995 }
39996
39997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39998         LDKu8slice ser_ref;
39999         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40000         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40001         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
40002         *ret_conv = AnnouncementSignatures_read(ser_ref);
40003         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40004         return tag_ptr(ret_conv, true);
40005 }
40006
40007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
40008         LDKChannelReestablish obj_conv;
40009         obj_conv.inner = untag_ptr(obj);
40010         obj_conv.is_owned = ptr_is_owned(obj);
40011         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40012         obj_conv.is_owned = false;
40013         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
40014         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40015         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40016         CVec_u8Z_free(ret_var);
40017         return ret_arr;
40018 }
40019
40020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40021         LDKu8slice ser_ref;
40022         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40023         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40024         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
40025         *ret_conv = ChannelReestablish_read(ser_ref);
40026         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40027         return tag_ptr(ret_conv, true);
40028 }
40029
40030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40031         LDKClosingSigned obj_conv;
40032         obj_conv.inner = untag_ptr(obj);
40033         obj_conv.is_owned = ptr_is_owned(obj);
40034         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40035         obj_conv.is_owned = false;
40036         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
40037         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40038         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40039         CVec_u8Z_free(ret_var);
40040         return ret_arr;
40041 }
40042
40043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40044         LDKu8slice ser_ref;
40045         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40046         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40047         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
40048         *ret_conv = ClosingSigned_read(ser_ref);
40049         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40050         return tag_ptr(ret_conv, true);
40051 }
40052
40053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40054         LDKClosingSignedFeeRange obj_conv;
40055         obj_conv.inner = untag_ptr(obj);
40056         obj_conv.is_owned = ptr_is_owned(obj);
40057         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40058         obj_conv.is_owned = false;
40059         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
40060         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40061         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40062         CVec_u8Z_free(ret_var);
40063         return ret_arr;
40064 }
40065
40066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40067         LDKu8slice ser_ref;
40068         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40069         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40070         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
40071         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
40072         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40073         return tag_ptr(ret_conv, true);
40074 }
40075
40076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40077         LDKCommitmentSigned obj_conv;
40078         obj_conv.inner = untag_ptr(obj);
40079         obj_conv.is_owned = ptr_is_owned(obj);
40080         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40081         obj_conv.is_owned = false;
40082         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
40083         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40084         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40085         CVec_u8Z_free(ret_var);
40086         return ret_arr;
40087 }
40088
40089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40090         LDKu8slice ser_ref;
40091         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40092         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40093         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
40094         *ret_conv = CommitmentSigned_read(ser_ref);
40095         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40096         return tag_ptr(ret_conv, true);
40097 }
40098
40099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
40100         LDKFundingCreated obj_conv;
40101         obj_conv.inner = untag_ptr(obj);
40102         obj_conv.is_owned = ptr_is_owned(obj);
40103         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40104         obj_conv.is_owned = false;
40105         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
40106         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40107         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40108         CVec_u8Z_free(ret_var);
40109         return ret_arr;
40110 }
40111
40112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40113         LDKu8slice ser_ref;
40114         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40115         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40116         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
40117         *ret_conv = FundingCreated_read(ser_ref);
40118         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40119         return tag_ptr(ret_conv, true);
40120 }
40121
40122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40123         LDKFundingSigned obj_conv;
40124         obj_conv.inner = untag_ptr(obj);
40125         obj_conv.is_owned = ptr_is_owned(obj);
40126         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40127         obj_conv.is_owned = false;
40128         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
40129         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40130         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40131         CVec_u8Z_free(ret_var);
40132         return ret_arr;
40133 }
40134
40135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40136         LDKu8slice ser_ref;
40137         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40138         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40139         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
40140         *ret_conv = FundingSigned_read(ser_ref);
40141         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40142         return tag_ptr(ret_conv, true);
40143 }
40144
40145 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
40146         LDKChannelReady obj_conv;
40147         obj_conv.inner = untag_ptr(obj);
40148         obj_conv.is_owned = ptr_is_owned(obj);
40149         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40150         obj_conv.is_owned = false;
40151         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
40152         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40153         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40154         CVec_u8Z_free(ret_var);
40155         return ret_arr;
40156 }
40157
40158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40159         LDKu8slice ser_ref;
40160         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40161         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40162         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
40163         *ret_conv = ChannelReady_read(ser_ref);
40164         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40165         return tag_ptr(ret_conv, true);
40166 }
40167
40168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
40169         LDKInit obj_conv;
40170         obj_conv.inner = untag_ptr(obj);
40171         obj_conv.is_owned = ptr_is_owned(obj);
40172         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40173         obj_conv.is_owned = false;
40174         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
40175         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40176         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40177         CVec_u8Z_free(ret_var);
40178         return ret_arr;
40179 }
40180
40181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40182         LDKu8slice ser_ref;
40183         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40184         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40185         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
40186         *ret_conv = Init_read(ser_ref);
40187         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40188         return tag_ptr(ret_conv, true);
40189 }
40190
40191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40192         LDKOpenChannel obj_conv;
40193         obj_conv.inner = untag_ptr(obj);
40194         obj_conv.is_owned = ptr_is_owned(obj);
40195         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40196         obj_conv.is_owned = false;
40197         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
40198         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40199         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40200         CVec_u8Z_free(ret_var);
40201         return ret_arr;
40202 }
40203
40204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40205         LDKu8slice ser_ref;
40206         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40207         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40208         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
40209         *ret_conv = OpenChannel_read(ser_ref);
40210         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40211         return tag_ptr(ret_conv, true);
40212 }
40213
40214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
40215         LDKRevokeAndACK obj_conv;
40216         obj_conv.inner = untag_ptr(obj);
40217         obj_conv.is_owned = ptr_is_owned(obj);
40218         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40219         obj_conv.is_owned = false;
40220         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
40221         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40222         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40223         CVec_u8Z_free(ret_var);
40224         return ret_arr;
40225 }
40226
40227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40228         LDKu8slice ser_ref;
40229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40231         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
40232         *ret_conv = RevokeAndACK_read(ser_ref);
40233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40234         return tag_ptr(ret_conv, true);
40235 }
40236
40237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
40238         LDKShutdown obj_conv;
40239         obj_conv.inner = untag_ptr(obj);
40240         obj_conv.is_owned = ptr_is_owned(obj);
40241         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40242         obj_conv.is_owned = false;
40243         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
40244         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40245         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40246         CVec_u8Z_free(ret_var);
40247         return ret_arr;
40248 }
40249
40250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40251         LDKu8slice ser_ref;
40252         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40253         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40254         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
40255         *ret_conv = Shutdown_read(ser_ref);
40256         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40257         return tag_ptr(ret_conv, true);
40258 }
40259
40260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40261         LDKUpdateFailHTLC obj_conv;
40262         obj_conv.inner = untag_ptr(obj);
40263         obj_conv.is_owned = ptr_is_owned(obj);
40264         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40265         obj_conv.is_owned = false;
40266         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
40267         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40268         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40269         CVec_u8Z_free(ret_var);
40270         return ret_arr;
40271 }
40272
40273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40274         LDKu8slice ser_ref;
40275         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40276         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40277         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
40278         *ret_conv = UpdateFailHTLC_read(ser_ref);
40279         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40280         return tag_ptr(ret_conv, true);
40281 }
40282
40283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40284         LDKUpdateFailMalformedHTLC obj_conv;
40285         obj_conv.inner = untag_ptr(obj);
40286         obj_conv.is_owned = ptr_is_owned(obj);
40287         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40288         obj_conv.is_owned = false;
40289         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
40290         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40291         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40292         CVec_u8Z_free(ret_var);
40293         return ret_arr;
40294 }
40295
40296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40297         LDKu8slice ser_ref;
40298         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40299         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40300         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
40301         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
40302         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40303         return tag_ptr(ret_conv, true);
40304 }
40305
40306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
40307         LDKUpdateFee obj_conv;
40308         obj_conv.inner = untag_ptr(obj);
40309         obj_conv.is_owned = ptr_is_owned(obj);
40310         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40311         obj_conv.is_owned = false;
40312         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
40313         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40314         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40315         CVec_u8Z_free(ret_var);
40316         return ret_arr;
40317 }
40318
40319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40320         LDKu8slice ser_ref;
40321         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40322         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40323         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
40324         *ret_conv = UpdateFee_read(ser_ref);
40325         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40326         return tag_ptr(ret_conv, true);
40327 }
40328
40329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40330         LDKUpdateFulfillHTLC obj_conv;
40331         obj_conv.inner = untag_ptr(obj);
40332         obj_conv.is_owned = ptr_is_owned(obj);
40333         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40334         obj_conv.is_owned = false;
40335         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
40336         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40337         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40338         CVec_u8Z_free(ret_var);
40339         return ret_arr;
40340 }
40341
40342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40343         LDKu8slice ser_ref;
40344         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40345         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40346         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
40347         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
40348         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40349         return tag_ptr(ret_conv, true);
40350 }
40351
40352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40353         LDKUpdateAddHTLC obj_conv;
40354         obj_conv.inner = untag_ptr(obj);
40355         obj_conv.is_owned = ptr_is_owned(obj);
40356         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40357         obj_conv.is_owned = false;
40358         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
40359         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40360         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40361         CVec_u8Z_free(ret_var);
40362         return ret_arr;
40363 }
40364
40365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40366         LDKu8slice ser_ref;
40367         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40368         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40369         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
40370         *ret_conv = UpdateAddHTLC_read(ser_ref);
40371         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40372         return tag_ptr(ret_conv, true);
40373 }
40374
40375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40376         LDKu8slice ser_ref;
40377         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40378         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40379         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
40380         *ret_conv = OnionMessage_read(ser_ref);
40381         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40382         return tag_ptr(ret_conv, true);
40383 }
40384
40385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
40386         LDKOnionMessage obj_conv;
40387         obj_conv.inner = untag_ptr(obj);
40388         obj_conv.is_owned = ptr_is_owned(obj);
40389         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40390         obj_conv.is_owned = false;
40391         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
40392         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40393         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40394         CVec_u8Z_free(ret_var);
40395         return ret_arr;
40396 }
40397
40398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
40399         LDKPing obj_conv;
40400         obj_conv.inner = untag_ptr(obj);
40401         obj_conv.is_owned = ptr_is_owned(obj);
40402         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40403         obj_conv.is_owned = false;
40404         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
40405         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40406         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40407         CVec_u8Z_free(ret_var);
40408         return ret_arr;
40409 }
40410
40411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40412         LDKu8slice ser_ref;
40413         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40414         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40415         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
40416         *ret_conv = Ping_read(ser_ref);
40417         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40418         return tag_ptr(ret_conv, true);
40419 }
40420
40421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
40422         LDKPong obj_conv;
40423         obj_conv.inner = untag_ptr(obj);
40424         obj_conv.is_owned = ptr_is_owned(obj);
40425         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40426         obj_conv.is_owned = false;
40427         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
40428         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40429         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40430         CVec_u8Z_free(ret_var);
40431         return ret_arr;
40432 }
40433
40434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40435         LDKu8slice ser_ref;
40436         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40437         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40438         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
40439         *ret_conv = Pong_read(ser_ref);
40440         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40441         return tag_ptr(ret_conv, true);
40442 }
40443
40444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40445         LDKUnsignedChannelAnnouncement obj_conv;
40446         obj_conv.inner = untag_ptr(obj);
40447         obj_conv.is_owned = ptr_is_owned(obj);
40448         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40449         obj_conv.is_owned = false;
40450         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
40451         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40452         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40453         CVec_u8Z_free(ret_var);
40454         return ret_arr;
40455 }
40456
40457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40458         LDKu8slice ser_ref;
40459         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40460         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40461         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
40462         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
40463         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40464         return tag_ptr(ret_conv, true);
40465 }
40466
40467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40468         LDKChannelAnnouncement obj_conv;
40469         obj_conv.inner = untag_ptr(obj);
40470         obj_conv.is_owned = ptr_is_owned(obj);
40471         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40472         obj_conv.is_owned = false;
40473         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
40474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40476         CVec_u8Z_free(ret_var);
40477         return ret_arr;
40478 }
40479
40480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40481         LDKu8slice ser_ref;
40482         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40483         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40484         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
40485         *ret_conv = ChannelAnnouncement_read(ser_ref);
40486         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40487         return tag_ptr(ret_conv, true);
40488 }
40489
40490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
40491         LDKUnsignedChannelUpdate obj_conv;
40492         obj_conv.inner = untag_ptr(obj);
40493         obj_conv.is_owned = ptr_is_owned(obj);
40494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40495         obj_conv.is_owned = false;
40496         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
40497         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40498         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40499         CVec_u8Z_free(ret_var);
40500         return ret_arr;
40501 }
40502
40503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40504         LDKu8slice ser_ref;
40505         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40506         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40507         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
40508         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
40509         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40510         return tag_ptr(ret_conv, true);
40511 }
40512
40513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
40514         LDKChannelUpdate obj_conv;
40515         obj_conv.inner = untag_ptr(obj);
40516         obj_conv.is_owned = ptr_is_owned(obj);
40517         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40518         obj_conv.is_owned = false;
40519         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
40520         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40521         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40522         CVec_u8Z_free(ret_var);
40523         return ret_arr;
40524 }
40525
40526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40527         LDKu8slice ser_ref;
40528         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40529         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40530         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
40531         *ret_conv = ChannelUpdate_read(ser_ref);
40532         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40533         return tag_ptr(ret_conv, true);
40534 }
40535
40536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
40537         LDKErrorMessage obj_conv;
40538         obj_conv.inner = untag_ptr(obj);
40539         obj_conv.is_owned = ptr_is_owned(obj);
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40541         obj_conv.is_owned = false;
40542         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
40543         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40544         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40545         CVec_u8Z_free(ret_var);
40546         return ret_arr;
40547 }
40548
40549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40550         LDKu8slice ser_ref;
40551         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40552         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40553         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
40554         *ret_conv = ErrorMessage_read(ser_ref);
40555         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40556         return tag_ptr(ret_conv, true);
40557 }
40558
40559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
40560         LDKWarningMessage obj_conv;
40561         obj_conv.inner = untag_ptr(obj);
40562         obj_conv.is_owned = ptr_is_owned(obj);
40563         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40564         obj_conv.is_owned = false;
40565         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
40566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40568         CVec_u8Z_free(ret_var);
40569         return ret_arr;
40570 }
40571
40572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40573         LDKu8slice ser_ref;
40574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40576         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
40577         *ret_conv = WarningMessage_read(ser_ref);
40578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40579         return tag_ptr(ret_conv, true);
40580 }
40581
40582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40583         LDKUnsignedNodeAnnouncement obj_conv;
40584         obj_conv.inner = untag_ptr(obj);
40585         obj_conv.is_owned = ptr_is_owned(obj);
40586         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40587         obj_conv.is_owned = false;
40588         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
40589         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40590         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40591         CVec_u8Z_free(ret_var);
40592         return ret_arr;
40593 }
40594
40595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40596         LDKu8slice ser_ref;
40597         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40598         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40599         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
40600         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
40601         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40602         return tag_ptr(ret_conv, true);
40603 }
40604
40605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40606         LDKNodeAnnouncement obj_conv;
40607         obj_conv.inner = untag_ptr(obj);
40608         obj_conv.is_owned = ptr_is_owned(obj);
40609         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40610         obj_conv.is_owned = false;
40611         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
40612         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40613         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40614         CVec_u8Z_free(ret_var);
40615         return ret_arr;
40616 }
40617
40618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40619         LDKu8slice ser_ref;
40620         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40621         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40622         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
40623         *ret_conv = NodeAnnouncement_read(ser_ref);
40624         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40625         return tag_ptr(ret_conv, true);
40626 }
40627
40628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40629         LDKu8slice ser_ref;
40630         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40631         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40632         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
40633         *ret_conv = QueryShortChannelIds_read(ser_ref);
40634         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40635         return tag_ptr(ret_conv, true);
40636 }
40637
40638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
40639         LDKQueryShortChannelIds obj_conv;
40640         obj_conv.inner = untag_ptr(obj);
40641         obj_conv.is_owned = ptr_is_owned(obj);
40642         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40643         obj_conv.is_owned = false;
40644         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
40645         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40646         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40647         CVec_u8Z_free(ret_var);
40648         return ret_arr;
40649 }
40650
40651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
40652         LDKReplyShortChannelIdsEnd obj_conv;
40653         obj_conv.inner = untag_ptr(obj);
40654         obj_conv.is_owned = ptr_is_owned(obj);
40655         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40656         obj_conv.is_owned = false;
40657         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
40658         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40659         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40660         CVec_u8Z_free(ret_var);
40661         return ret_arr;
40662 }
40663
40664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40665         LDKu8slice ser_ref;
40666         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40667         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40668         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
40669         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
40670         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40671         return tag_ptr(ret_conv, true);
40672 }
40673
40674 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
40675         LDKQueryChannelRange this_arg_conv;
40676         this_arg_conv.inner = untag_ptr(this_arg);
40677         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40679         this_arg_conv.is_owned = false;
40680         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
40681         return ret_conv;
40682 }
40683
40684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40685         LDKQueryChannelRange obj_conv;
40686         obj_conv.inner = untag_ptr(obj);
40687         obj_conv.is_owned = ptr_is_owned(obj);
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40689         obj_conv.is_owned = false;
40690         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
40691         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40692         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40693         CVec_u8Z_free(ret_var);
40694         return ret_arr;
40695 }
40696
40697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40698         LDKu8slice ser_ref;
40699         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40700         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40701         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
40702         *ret_conv = QueryChannelRange_read(ser_ref);
40703         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40704         return tag_ptr(ret_conv, true);
40705 }
40706
40707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40708         LDKu8slice ser_ref;
40709         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40710         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40711         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
40712         *ret_conv = ReplyChannelRange_read(ser_ref);
40713         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40714         return tag_ptr(ret_conv, true);
40715 }
40716
40717 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40718         LDKReplyChannelRange obj_conv;
40719         obj_conv.inner = untag_ptr(obj);
40720         obj_conv.is_owned = ptr_is_owned(obj);
40721         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40722         obj_conv.is_owned = false;
40723         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
40724         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40725         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40726         CVec_u8Z_free(ret_var);
40727         return ret_arr;
40728 }
40729
40730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
40731         LDKGossipTimestampFilter obj_conv;
40732         obj_conv.inner = untag_ptr(obj);
40733         obj_conv.is_owned = ptr_is_owned(obj);
40734         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40735         obj_conv.is_owned = false;
40736         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
40737         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40738         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40739         CVec_u8Z_free(ret_var);
40740         return ret_arr;
40741 }
40742
40743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40744         LDKu8slice ser_ref;
40745         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40746         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40747         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
40748         *ret_conv = GossipTimestampFilter_read(ser_ref);
40749         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40750         return tag_ptr(ret_conv, true);
40751 }
40752
40753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40754         if (!ptr_is_owned(this_ptr)) return;
40755         void* this_ptr_ptr = untag_ptr(this_ptr);
40756         CHECK_ACCESS(this_ptr_ptr);
40757         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
40758         FREE(untag_ptr(this_ptr));
40759         CustomMessageHandler_free(this_ptr_conv);
40760 }
40761
40762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40763         LDKIgnoringMessageHandler this_obj_conv;
40764         this_obj_conv.inner = untag_ptr(this_obj);
40765         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40767         IgnoringMessageHandler_free(this_obj_conv);
40768 }
40769
40770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
40771         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
40772         int64_t ret_ref = 0;
40773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40775         return ret_ref;
40776 }
40777
40778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
40779         LDKIgnoringMessageHandler this_arg_conv;
40780         this_arg_conv.inner = untag_ptr(this_arg);
40781         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40783         this_arg_conv.is_owned = false;
40784         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
40785         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
40786         return tag_ptr(ret_ret, true);
40787 }
40788
40789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40790         LDKIgnoringMessageHandler this_arg_conv;
40791         this_arg_conv.inner = untag_ptr(this_arg);
40792         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40794         this_arg_conv.is_owned = false;
40795         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
40796         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
40797         return tag_ptr(ret_ret, true);
40798 }
40799
40800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
40801         LDKIgnoringMessageHandler this_arg_conv;
40802         this_arg_conv.inner = untag_ptr(this_arg);
40803         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40805         this_arg_conv.is_owned = false;
40806         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
40807         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
40808         return tag_ptr(ret_ret, true);
40809 }
40810
40811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40812         LDKIgnoringMessageHandler this_arg_conv;
40813         this_arg_conv.inner = untag_ptr(this_arg);
40814         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40816         this_arg_conv.is_owned = false;
40817         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
40818         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
40819         return tag_ptr(ret_ret, true);
40820 }
40821
40822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40823         LDKIgnoringMessageHandler this_arg_conv;
40824         this_arg_conv.inner = untag_ptr(this_arg);
40825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40827         this_arg_conv.is_owned = false;
40828         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
40829         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
40830         return tag_ptr(ret_ret, true);
40831 }
40832
40833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
40834         LDKIgnoringMessageHandler this_arg_conv;
40835         this_arg_conv.inner = untag_ptr(this_arg);
40836         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40838         this_arg_conv.is_owned = false;
40839         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
40840         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
40841         return tag_ptr(ret_ret, true);
40842 }
40843
40844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40845         LDKIgnoringMessageHandler this_arg_conv;
40846         this_arg_conv.inner = untag_ptr(this_arg);
40847         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40849         this_arg_conv.is_owned = false;
40850         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
40851         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
40852         return tag_ptr(ret_ret, true);
40853 }
40854
40855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40856         LDKErroringMessageHandler this_obj_conv;
40857         this_obj_conv.inner = untag_ptr(this_obj);
40858         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40860         ErroringMessageHandler_free(this_obj_conv);
40861 }
40862
40863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
40864         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
40865         int64_t ret_ref = 0;
40866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40868         return ret_ref;
40869 }
40870
40871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
40872         LDKErroringMessageHandler this_arg_conv;
40873         this_arg_conv.inner = untag_ptr(this_arg);
40874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40876         this_arg_conv.is_owned = false;
40877         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
40878         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
40879         return tag_ptr(ret_ret, true);
40880 }
40881
40882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40883         LDKErroringMessageHandler this_arg_conv;
40884         this_arg_conv.inner = untag_ptr(this_arg);
40885         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40887         this_arg_conv.is_owned = false;
40888         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
40889         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
40890         return tag_ptr(ret_ret, true);
40891 }
40892
40893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40894         LDKMessageHandler this_obj_conv;
40895         this_obj_conv.inner = untag_ptr(this_obj);
40896         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40898         MessageHandler_free(this_obj_conv);
40899 }
40900
40901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
40902         LDKMessageHandler this_ptr_conv;
40903         this_ptr_conv.inner = untag_ptr(this_ptr);
40904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40906         this_ptr_conv.is_owned = false;
40907         // WARNING: This object doesn't live past this scope, needs clone!
40908         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
40909         return ret_ret;
40910 }
40911
40912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40913         LDKMessageHandler this_ptr_conv;
40914         this_ptr_conv.inner = untag_ptr(this_ptr);
40915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40917         this_ptr_conv.is_owned = false;
40918         void* val_ptr = untag_ptr(val);
40919         CHECK_ACCESS(val_ptr);
40920         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
40921         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
40922                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40923                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
40924         }
40925         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
40926 }
40927
40928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
40929         LDKMessageHandler this_ptr_conv;
40930         this_ptr_conv.inner = untag_ptr(this_ptr);
40931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40933         this_ptr_conv.is_owned = false;
40934         // WARNING: This object doesn't live past this scope, needs clone!
40935         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
40936         return ret_ret;
40937 }
40938
40939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40940         LDKMessageHandler this_ptr_conv;
40941         this_ptr_conv.inner = untag_ptr(this_ptr);
40942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40944         this_ptr_conv.is_owned = false;
40945         void* val_ptr = untag_ptr(val);
40946         CHECK_ACCESS(val_ptr);
40947         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
40948         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
40949                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40950                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
40951         }
40952         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
40953 }
40954
40955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
40956         LDKMessageHandler this_ptr_conv;
40957         this_ptr_conv.inner = untag_ptr(this_ptr);
40958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40960         this_ptr_conv.is_owned = false;
40961         // WARNING: This object doesn't live past this scope, needs clone!
40962         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
40963         return ret_ret;
40964 }
40965
40966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40967         LDKMessageHandler this_ptr_conv;
40968         this_ptr_conv.inner = untag_ptr(this_ptr);
40969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40971         this_ptr_conv.is_owned = false;
40972         void* val_ptr = untag_ptr(val);
40973         CHECK_ACCESS(val_ptr);
40974         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
40975         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
40976                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40977                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
40978         }
40979         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
40980 }
40981
40982 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) {
40983         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
40984         CHECK_ACCESS(chan_handler_arg_ptr);
40985         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
40986         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
40987                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40988                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
40989         }
40990         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
40991         CHECK_ACCESS(route_handler_arg_ptr);
40992         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
40993         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
40994                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40995                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
40996         }
40997         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
40998         CHECK_ACCESS(onion_message_handler_arg_ptr);
40999         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
41000         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
41001                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41002                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
41003         }
41004         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
41005         int64_t ret_ref = 0;
41006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41008         return ret_ref;
41009 }
41010
41011 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
41012         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41013         *ret_ret = SocketDescriptor_clone(arg);
41014         return tag_ptr(ret_ret, true);
41015 }
41016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41017         void* arg_ptr = untag_ptr(arg);
41018         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41019         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
41020         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
41021         return ret_conv;
41022 }
41023
41024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41025         void* orig_ptr = untag_ptr(orig);
41026         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41027         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
41028         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41029         *ret_ret = SocketDescriptor_clone(orig_conv);
41030         return tag_ptr(ret_ret, true);
41031 }
41032
41033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41034         if (!ptr_is_owned(this_ptr)) return;
41035         void* this_ptr_ptr = untag_ptr(this_ptr);
41036         CHECK_ACCESS(this_ptr_ptr);
41037         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
41038         FREE(untag_ptr(this_ptr));
41039         SocketDescriptor_free(this_ptr_conv);
41040 }
41041
41042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41043         LDKPeerHandleError this_obj_conv;
41044         this_obj_conv.inner = untag_ptr(this_obj);
41045         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41047         PeerHandleError_free(this_obj_conv);
41048 }
41049
41050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
41051         LDKPeerHandleError this_ptr_conv;
41052         this_ptr_conv.inner = untag_ptr(this_ptr);
41053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41055         this_ptr_conv.is_owned = false;
41056         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
41057         return ret_conv;
41058 }
41059
41060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
41061         LDKPeerHandleError this_ptr_conv;
41062         this_ptr_conv.inner = untag_ptr(this_ptr);
41063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41065         this_ptr_conv.is_owned = false;
41066         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
41067 }
41068
41069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
41070         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
41071         int64_t ret_ref = 0;
41072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41074         return ret_ref;
41075 }
41076
41077 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
41078         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
41079         int64_t ret_ref = 0;
41080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41082         return ret_ref;
41083 }
41084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41085         LDKPeerHandleError arg_conv;
41086         arg_conv.inner = untag_ptr(arg);
41087         arg_conv.is_owned = ptr_is_owned(arg);
41088         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41089         arg_conv.is_owned = false;
41090         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
41091         return ret_conv;
41092 }
41093
41094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41095         LDKPeerHandleError orig_conv;
41096         orig_conv.inner = untag_ptr(orig);
41097         orig_conv.is_owned = ptr_is_owned(orig);
41098         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41099         orig_conv.is_owned = false;
41100         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
41101         int64_t ret_ref = 0;
41102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41104         return ret_ref;
41105 }
41106
41107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41108         LDKPeerManager this_obj_conv;
41109         this_obj_conv.inner = untag_ptr(this_obj);
41110         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41112         PeerManager_free(this_obj_conv);
41113 }
41114
41115 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) {
41116         LDKMessageHandler message_handler_conv;
41117         message_handler_conv.inner = untag_ptr(message_handler);
41118         message_handler_conv.is_owned = ptr_is_owned(message_handler);
41119         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
41120         // WARNING: we need a move here but no clone is available for LDKMessageHandler
41121         
41122         LDKSecretKey our_node_secret_ref;
41123         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
41124         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
41125         unsigned char ephemeral_random_data_arr[32];
41126         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
41127         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
41128         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
41129         void* logger_ptr = untag_ptr(logger);
41130         CHECK_ACCESS(logger_ptr);
41131         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41132         if (logger_conv.free == LDKLogger_JCalls_free) {
41133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41134                 LDKLogger_JCalls_cloned(&logger_conv);
41135         }
41136         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
41137         CHECK_ACCESS(custom_message_handler_ptr);
41138         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
41139         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
41140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41141                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
41142         }
41143         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
41144         int64_t ret_ref = 0;
41145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41147         return ret_ref;
41148 }
41149
41150 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
41151         LDKPeerManager this_arg_conv;
41152         this_arg_conv.inner = untag_ptr(this_arg);
41153         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41155         this_arg_conv.is_owned = false;
41156         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
41157         jobjectArray ret_arr = NULL;
41158         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
41159         ;
41160         for (size_t i = 0; i < ret_var.datalen; i++) {
41161                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
41162                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
41163                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
41164         }
41165         
41166         FREE(ret_var.data);
41167         return ret_arr;
41168 }
41169
41170 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) {
41171         LDKPeerManager this_arg_conv;
41172         this_arg_conv.inner = untag_ptr(this_arg);
41173         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41175         this_arg_conv.is_owned = false;
41176         LDKPublicKey their_node_id_ref;
41177         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
41178         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
41179         void* descriptor_ptr = untag_ptr(descriptor);
41180         CHECK_ACCESS(descriptor_ptr);
41181         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41182         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
41183                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41184                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
41185         }
41186         void* remote_network_address_ptr = untag_ptr(remote_network_address);
41187         CHECK_ACCESS(remote_network_address_ptr);
41188         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
41189         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
41190         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
41191         return tag_ptr(ret_conv, true);
41192 }
41193
41194 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) {
41195         LDKPeerManager this_arg_conv;
41196         this_arg_conv.inner = untag_ptr(this_arg);
41197         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41199         this_arg_conv.is_owned = false;
41200         void* descriptor_ptr = untag_ptr(descriptor);
41201         CHECK_ACCESS(descriptor_ptr);
41202         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41203         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
41204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41205                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
41206         }
41207         void* remote_network_address_ptr = untag_ptr(remote_network_address);
41208         CHECK_ACCESS(remote_network_address_ptr);
41209         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
41210         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
41211         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
41212         return tag_ptr(ret_conv, true);
41213 }
41214
41215 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) {
41216         LDKPeerManager this_arg_conv;
41217         this_arg_conv.inner = untag_ptr(this_arg);
41218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41220         this_arg_conv.is_owned = false;
41221         void* descriptor_ptr = untag_ptr(descriptor);
41222         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
41223         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
41224         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
41225         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
41226         return tag_ptr(ret_conv, true);
41227 }
41228
41229 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) {
41230         LDKPeerManager this_arg_conv;
41231         this_arg_conv.inner = untag_ptr(this_arg);
41232         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41234         this_arg_conv.is_owned = false;
41235         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
41236         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
41237         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
41238         LDKu8slice data_ref;
41239         data_ref.datalen = (*env)->GetArrayLength(env, data);
41240         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
41241         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
41242         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
41243         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
41244         return tag_ptr(ret_conv, true);
41245 }
41246
41247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
41248         LDKPeerManager this_arg_conv;
41249         this_arg_conv.inner = untag_ptr(this_arg);
41250         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41252         this_arg_conv.is_owned = false;
41253         PeerManager_process_events(&this_arg_conv);
41254 }
41255
41256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
41257         LDKPeerManager this_arg_conv;
41258         this_arg_conv.inner = untag_ptr(this_arg);
41259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41261         this_arg_conv.is_owned = false;
41262         void* descriptor_ptr = untag_ptr(descriptor);
41263         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
41264         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
41265         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
41266 }
41267
41268 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) {
41269         LDKPeerManager this_arg_conv;
41270         this_arg_conv.inner = untag_ptr(this_arg);
41271         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41273         this_arg_conv.is_owned = false;
41274         LDKPublicKey node_id_ref;
41275         CHECK((*env)->GetArrayLength(env, node_id) == 33);
41276         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
41277         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
41278 }
41279
41280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
41281         LDKPeerManager this_arg_conv;
41282         this_arg_conv.inner = untag_ptr(this_arg);
41283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41285         this_arg_conv.is_owned = false;
41286         PeerManager_disconnect_all_peers(&this_arg_conv);
41287 }
41288
41289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
41290         LDKPeerManager this_arg_conv;
41291         this_arg_conv.inner = untag_ptr(this_arg);
41292         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41294         this_arg_conv.is_owned = false;
41295         PeerManager_timer_tick_occurred(&this_arg_conv);
41296 }
41297
41298 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) {
41299         LDKPeerManager this_arg_conv;
41300         this_arg_conv.inner = untag_ptr(this_arg);
41301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41303         this_arg_conv.is_owned = false;
41304         LDKThreeBytes rgb_ref;
41305         CHECK((*env)->GetArrayLength(env, rgb) == 3);
41306         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
41307         LDKThirtyTwoBytes alias_ref;
41308         CHECK((*env)->GetArrayLength(env, alias) == 32);
41309         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
41310         LDKCVec_NetAddressZ addresses_constr;
41311         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
41312         if (addresses_constr.datalen > 0)
41313                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
41314         else
41315                 addresses_constr.data = NULL;
41316         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
41317         for (size_t m = 0; m < addresses_constr.datalen; m++) {
41318                 int64_t addresses_conv_12 = addresses_vals[m];
41319                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
41320                 CHECK_ACCESS(addresses_conv_12_ptr);
41321                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
41322                 addresses_constr.data[m] = addresses_conv_12_conv;
41323         }
41324         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
41325         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
41326 }
41327
41328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
41329         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
41330         return ret_conv;
41331 }
41332
41333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
41334         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
41335         return ret_conv;
41336 }
41337
41338 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41339         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
41340         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_clone(orig_conv));
41341         return ret_conv;
41342 }
41343
41344 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1timeout(JNIEnv *env, jclass clz) {
41345         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_timeout());
41346         return ret_conv;
41347 }
41348
41349 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1preimage(JNIEnv *env, jclass clz) {
41350         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_preimage());
41351         return ret_conv;
41352 }
41353
41354 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1timeout(JNIEnv *env, jclass clz) {
41355         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_timeout());
41356         return ret_conv;
41357 }
41358
41359 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1preimage(JNIEnv *env, jclass clz) {
41360         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_preimage());
41361         return ret_conv;
41362 }
41363
41364 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1revocation(JNIEnv *env, jclass clz) {
41365         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_revocation());
41366         return ret_conv;
41367 }
41368
41369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41370         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
41371         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
41372         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
41373         return ret_conv;
41374 }
41375
41376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1from_1witness(JNIEnv *env, jclass clz, int8_tArray witness) {
41377         LDKWitness witness_ref;
41378         witness_ref.datalen = (*env)->GetArrayLength(env, witness);
41379         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
41380         (*env)->GetByteArrayRegion(env, witness, 0, witness_ref.datalen, witness_ref.data);
41381         witness_ref.data_is_owned = true;
41382         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
41383         *ret_copy = HTLCClaim_from_witness(witness_ref);
41384         int64_t ret_ref = tag_ptr(ret_copy, true);
41385         return ret_ref;
41386 }
41387
41388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
41389         unsigned char commitment_seed_arr[32];
41390         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
41391         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
41392         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
41393         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
41395         return ret_arr;
41396 }
41397
41398 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) {
41399         LDKCVec_u8Z to_holder_script_ref;
41400         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
41401         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
41402         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
41403         LDKCVec_u8Z to_counterparty_script_ref;
41404         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
41405         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
41406         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
41407         LDKOutPoint funding_outpoint_conv;
41408         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
41409         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
41410         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
41411         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
41412         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);
41413         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41414         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41415         Transaction_free(ret_var);
41416         return ret_arr;
41417 }
41418
41419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41420         LDKCounterpartyCommitmentSecrets this_obj_conv;
41421         this_obj_conv.inner = untag_ptr(this_obj);
41422         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41424         CounterpartyCommitmentSecrets_free(this_obj_conv);
41425 }
41426
41427 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
41428         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
41429         int64_t ret_ref = 0;
41430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41431         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41432         return ret_ref;
41433 }
41434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41435         LDKCounterpartyCommitmentSecrets arg_conv;
41436         arg_conv.inner = untag_ptr(arg);
41437         arg_conv.is_owned = ptr_is_owned(arg);
41438         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41439         arg_conv.is_owned = false;
41440         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
41441         return ret_conv;
41442 }
41443
41444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41445         LDKCounterpartyCommitmentSecrets orig_conv;
41446         orig_conv.inner = untag_ptr(orig);
41447         orig_conv.is_owned = ptr_is_owned(orig);
41448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41449         orig_conv.is_owned = false;
41450         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
41451         int64_t ret_ref = 0;
41452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41453         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41454         return ret_ref;
41455 }
41456
41457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
41458         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
41459         int64_t ret_ref = 0;
41460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41462         return ret_ref;
41463 }
41464
41465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41466         LDKCounterpartyCommitmentSecrets this_arg_conv;
41467         this_arg_conv.inner = untag_ptr(this_arg);
41468         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41470         this_arg_conv.is_owned = false;
41471         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
41472         return ret_conv;
41473 }
41474
41475 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) {
41476         LDKCounterpartyCommitmentSecrets this_arg_conv;
41477         this_arg_conv.inner = untag_ptr(this_arg);
41478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41480         this_arg_conv.is_owned = false;
41481         LDKThirtyTwoBytes secret_ref;
41482         CHECK((*env)->GetArrayLength(env, secret) == 32);
41483         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
41484         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
41485         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
41486         return tag_ptr(ret_conv, true);
41487 }
41488
41489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
41490         LDKCounterpartyCommitmentSecrets this_arg_conv;
41491         this_arg_conv.inner = untag_ptr(this_arg);
41492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41494         this_arg_conv.is_owned = false;
41495         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41496         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
41497         return ret_arr;
41498 }
41499
41500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
41501         LDKCounterpartyCommitmentSecrets obj_conv;
41502         obj_conv.inner = untag_ptr(obj);
41503         obj_conv.is_owned = ptr_is_owned(obj);
41504         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41505         obj_conv.is_owned = false;
41506         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
41507         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41508         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41509         CVec_u8Z_free(ret_var);
41510         return ret_arr;
41511 }
41512
41513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41514         LDKu8slice ser_ref;
41515         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41516         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41517         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
41518         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
41519         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41520         return tag_ptr(ret_conv, true);
41521 }
41522
41523 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) {
41524         LDKPublicKey per_commitment_point_ref;
41525         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
41526         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
41527         unsigned char base_secret_arr[32];
41528         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
41529         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
41530         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
41531         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41532         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes);
41533         return ret_arr;
41534 }
41535
41536 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) {
41537         LDKPublicKey per_commitment_point_ref;
41538         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
41539         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
41540         LDKPublicKey base_point_ref;
41541         CHECK((*env)->GetArrayLength(env, base_point) == 33);
41542         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
41543         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41544         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form);
41545         return ret_arr;
41546 }
41547
41548 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) {
41549         unsigned char per_commitment_secret_arr[32];
41550         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
41551         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
41552         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
41553         unsigned char countersignatory_revocation_base_secret_arr[32];
41554         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
41555         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
41556         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
41557         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes);
41559         return ret_arr;
41560 }
41561
41562 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) {
41563         LDKPublicKey per_commitment_point_ref;
41564         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
41565         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
41566         LDKPublicKey countersignatory_revocation_base_point_ref;
41567         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
41568         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
41569         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form);
41571         return ret_arr;
41572 }
41573
41574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41575         LDKTxCreationKeys this_obj_conv;
41576         this_obj_conv.inner = untag_ptr(this_obj);
41577         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41579         TxCreationKeys_free(this_obj_conv);
41580 }
41581
41582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
41583         LDKTxCreationKeys this_ptr_conv;
41584         this_ptr_conv.inner = untag_ptr(this_ptr);
41585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41587         this_ptr_conv.is_owned = false;
41588         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41589         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
41590         return ret_arr;
41591 }
41592
41593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41594         LDKTxCreationKeys this_ptr_conv;
41595         this_ptr_conv.inner = untag_ptr(this_ptr);
41596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41598         this_ptr_conv.is_owned = false;
41599         LDKPublicKey val_ref;
41600         CHECK((*env)->GetArrayLength(env, val) == 33);
41601         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41602         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
41603 }
41604
41605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41606         LDKTxCreationKeys this_ptr_conv;
41607         this_ptr_conv.inner = untag_ptr(this_ptr);
41608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41610         this_ptr_conv.is_owned = false;
41611         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
41613         return ret_arr;
41614 }
41615
41616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41617         LDKTxCreationKeys this_ptr_conv;
41618         this_ptr_conv.inner = untag_ptr(this_ptr);
41619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41621         this_ptr_conv.is_owned = false;
41622         LDKPublicKey val_ref;
41623         CHECK((*env)->GetArrayLength(env, val) == 33);
41624         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41625         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
41626 }
41627
41628 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41629         LDKTxCreationKeys this_ptr_conv;
41630         this_ptr_conv.inner = untag_ptr(this_ptr);
41631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41633         this_ptr_conv.is_owned = false;
41634         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41635         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
41636         return ret_arr;
41637 }
41638
41639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41640         LDKTxCreationKeys this_ptr_conv;
41641         this_ptr_conv.inner = untag_ptr(this_ptr);
41642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41644         this_ptr_conv.is_owned = false;
41645         LDKPublicKey val_ref;
41646         CHECK((*env)->GetArrayLength(env, val) == 33);
41647         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41648         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
41649 }
41650
41651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41652         LDKTxCreationKeys this_ptr_conv;
41653         this_ptr_conv.inner = untag_ptr(this_ptr);
41654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41656         this_ptr_conv.is_owned = false;
41657         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41658         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
41659         return ret_arr;
41660 }
41661
41662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41663         LDKTxCreationKeys this_ptr_conv;
41664         this_ptr_conv.inner = untag_ptr(this_ptr);
41665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41667         this_ptr_conv.is_owned = false;
41668         LDKPublicKey val_ref;
41669         CHECK((*env)->GetArrayLength(env, val) == 33);
41670         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41671         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
41672 }
41673
41674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41675         LDKTxCreationKeys this_ptr_conv;
41676         this_ptr_conv.inner = untag_ptr(this_ptr);
41677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41679         this_ptr_conv.is_owned = false;
41680         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41681         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
41682         return ret_arr;
41683 }
41684
41685 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) {
41686         LDKTxCreationKeys this_ptr_conv;
41687         this_ptr_conv.inner = untag_ptr(this_ptr);
41688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41690         this_ptr_conv.is_owned = false;
41691         LDKPublicKey val_ref;
41692         CHECK((*env)->GetArrayLength(env, val) == 33);
41693         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41694         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
41695 }
41696
41697 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) {
41698         LDKPublicKey per_commitment_point_arg_ref;
41699         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
41700         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
41701         LDKPublicKey revocation_key_arg_ref;
41702         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
41703         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
41704         LDKPublicKey broadcaster_htlc_key_arg_ref;
41705         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
41706         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
41707         LDKPublicKey countersignatory_htlc_key_arg_ref;
41708         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
41709         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
41710         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
41711         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
41712         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
41713         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);
41714         int64_t ret_ref = 0;
41715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41717         return ret_ref;
41718 }
41719
41720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41721         LDKTxCreationKeys a_conv;
41722         a_conv.inner = untag_ptr(a);
41723         a_conv.is_owned = ptr_is_owned(a);
41724         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41725         a_conv.is_owned = false;
41726         LDKTxCreationKeys b_conv;
41727         b_conv.inner = untag_ptr(b);
41728         b_conv.is_owned = ptr_is_owned(b);
41729         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41730         b_conv.is_owned = false;
41731         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
41732         return ret_conv;
41733 }
41734
41735 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
41736         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
41737         int64_t ret_ref = 0;
41738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41740         return ret_ref;
41741 }
41742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41743         LDKTxCreationKeys arg_conv;
41744         arg_conv.inner = untag_ptr(arg);
41745         arg_conv.is_owned = ptr_is_owned(arg);
41746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41747         arg_conv.is_owned = false;
41748         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
41749         return ret_conv;
41750 }
41751
41752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41753         LDKTxCreationKeys orig_conv;
41754         orig_conv.inner = untag_ptr(orig);
41755         orig_conv.is_owned = ptr_is_owned(orig);
41756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41757         orig_conv.is_owned = false;
41758         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
41759         int64_t ret_ref = 0;
41760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41762         return ret_ref;
41763 }
41764
41765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
41766         LDKTxCreationKeys obj_conv;
41767         obj_conv.inner = untag_ptr(obj);
41768         obj_conv.is_owned = ptr_is_owned(obj);
41769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41770         obj_conv.is_owned = false;
41771         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
41772         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41773         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41774         CVec_u8Z_free(ret_var);
41775         return ret_arr;
41776 }
41777
41778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41779         LDKu8slice ser_ref;
41780         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41781         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41782         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
41783         *ret_conv = TxCreationKeys_read(ser_ref);
41784         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41785         return tag_ptr(ret_conv, true);
41786 }
41787
41788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41789         LDKChannelPublicKeys this_obj_conv;
41790         this_obj_conv.inner = untag_ptr(this_obj);
41791         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41793         ChannelPublicKeys_free(this_obj_conv);
41794 }
41795
41796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
41797         LDKChannelPublicKeys this_ptr_conv;
41798         this_ptr_conv.inner = untag_ptr(this_ptr);
41799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41801         this_ptr_conv.is_owned = false;
41802         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41803         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
41804         return ret_arr;
41805 }
41806
41807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41808         LDKChannelPublicKeys this_ptr_conv;
41809         this_ptr_conv.inner = untag_ptr(this_ptr);
41810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41812         this_ptr_conv.is_owned = false;
41813         LDKPublicKey val_ref;
41814         CHECK((*env)->GetArrayLength(env, val) == 33);
41815         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41816         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
41817 }
41818
41819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41820         LDKChannelPublicKeys this_ptr_conv;
41821         this_ptr_conv.inner = untag_ptr(this_ptr);
41822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41824         this_ptr_conv.is_owned = false;
41825         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41826         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
41827         return ret_arr;
41828 }
41829
41830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41831         LDKChannelPublicKeys this_ptr_conv;
41832         this_ptr_conv.inner = untag_ptr(this_ptr);
41833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41835         this_ptr_conv.is_owned = false;
41836         LDKPublicKey val_ref;
41837         CHECK((*env)->GetArrayLength(env, val) == 33);
41838         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41839         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
41840 }
41841
41842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
41843         LDKChannelPublicKeys this_ptr_conv;
41844         this_ptr_conv.inner = untag_ptr(this_ptr);
41845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41847         this_ptr_conv.is_owned = false;
41848         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
41850         return ret_arr;
41851 }
41852
41853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41854         LDKChannelPublicKeys this_ptr_conv;
41855         this_ptr_conv.inner = untag_ptr(this_ptr);
41856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41858         this_ptr_conv.is_owned = false;
41859         LDKPublicKey val_ref;
41860         CHECK((*env)->GetArrayLength(env, val) == 33);
41861         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41862         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
41863 }
41864
41865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41866         LDKChannelPublicKeys this_ptr_conv;
41867         this_ptr_conv.inner = untag_ptr(this_ptr);
41868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41870         this_ptr_conv.is_owned = false;
41871         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41872         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
41873         return ret_arr;
41874 }
41875
41876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41877         LDKChannelPublicKeys this_ptr_conv;
41878         this_ptr_conv.inner = untag_ptr(this_ptr);
41879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41881         this_ptr_conv.is_owned = false;
41882         LDKPublicKey val_ref;
41883         CHECK((*env)->GetArrayLength(env, val) == 33);
41884         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41885         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
41886 }
41887
41888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41889         LDKChannelPublicKeys this_ptr_conv;
41890         this_ptr_conv.inner = untag_ptr(this_ptr);
41891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41893         this_ptr_conv.is_owned = false;
41894         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41895         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
41896         return ret_arr;
41897 }
41898
41899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41900         LDKChannelPublicKeys this_ptr_conv;
41901         this_ptr_conv.inner = untag_ptr(this_ptr);
41902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41904         this_ptr_conv.is_owned = false;
41905         LDKPublicKey val_ref;
41906         CHECK((*env)->GetArrayLength(env, val) == 33);
41907         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41908         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
41909 }
41910
41911 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) {
41912         LDKPublicKey funding_pubkey_arg_ref;
41913         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
41914         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
41915         LDKPublicKey revocation_basepoint_arg_ref;
41916         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
41917         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
41918         LDKPublicKey payment_point_arg_ref;
41919         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
41920         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
41921         LDKPublicKey delayed_payment_basepoint_arg_ref;
41922         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
41923         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
41924         LDKPublicKey htlc_basepoint_arg_ref;
41925         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
41926         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
41927         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);
41928         int64_t ret_ref = 0;
41929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41931         return ret_ref;
41932 }
41933
41934 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
41935         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
41936         int64_t ret_ref = 0;
41937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41939         return ret_ref;
41940 }
41941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41942         LDKChannelPublicKeys arg_conv;
41943         arg_conv.inner = untag_ptr(arg);
41944         arg_conv.is_owned = ptr_is_owned(arg);
41945         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41946         arg_conv.is_owned = false;
41947         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
41948         return ret_conv;
41949 }
41950
41951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41952         LDKChannelPublicKeys orig_conv;
41953         orig_conv.inner = untag_ptr(orig);
41954         orig_conv.is_owned = ptr_is_owned(orig);
41955         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41956         orig_conv.is_owned = false;
41957         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
41958         int64_t ret_ref = 0;
41959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41961         return ret_ref;
41962 }
41963
41964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41965         LDKChannelPublicKeys a_conv;
41966         a_conv.inner = untag_ptr(a);
41967         a_conv.is_owned = ptr_is_owned(a);
41968         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41969         a_conv.is_owned = false;
41970         LDKChannelPublicKeys b_conv;
41971         b_conv.inner = untag_ptr(b);
41972         b_conv.is_owned = ptr_is_owned(b);
41973         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41974         b_conv.is_owned = false;
41975         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
41976         return ret_conv;
41977 }
41978
41979 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
41980         LDKChannelPublicKeys obj_conv;
41981         obj_conv.inner = untag_ptr(obj);
41982         obj_conv.is_owned = ptr_is_owned(obj);
41983         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41984         obj_conv.is_owned = false;
41985         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
41986         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41987         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41988         CVec_u8Z_free(ret_var);
41989         return ret_arr;
41990 }
41991
41992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41993         LDKu8slice ser_ref;
41994         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41995         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41996         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
41997         *ret_conv = ChannelPublicKeys_read(ser_ref);
41998         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41999         return tag_ptr(ret_conv, true);
42000 }
42001
42002 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) {
42003         LDKPublicKey per_commitment_point_ref;
42004         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42005         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42006         LDKPublicKey broadcaster_delayed_payment_base_ref;
42007         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
42008         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
42009         LDKPublicKey broadcaster_htlc_base_ref;
42010         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
42011         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
42012         LDKPublicKey countersignatory_revocation_base_ref;
42013         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
42014         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
42015         LDKPublicKey countersignatory_htlc_base_ref;
42016         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
42017         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
42018         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);
42019         int64_t ret_ref = 0;
42020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42022         return ret_ref;
42023 }
42024
42025 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) {
42026         LDKPublicKey per_commitment_point_ref;
42027         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42028         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42029         LDKChannelPublicKeys broadcaster_keys_conv;
42030         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42031         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42032         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42033         broadcaster_keys_conv.is_owned = false;
42034         LDKChannelPublicKeys countersignatory_keys_conv;
42035         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42036         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42037         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42038         countersignatory_keys_conv.is_owned = false;
42039         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
42040         int64_t ret_ref = 0;
42041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42043         return ret_ref;
42044 }
42045
42046 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) {
42047         LDKPublicKey revocation_key_ref;
42048         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42049         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42050         LDKPublicKey broadcaster_delayed_payment_key_ref;
42051         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42052         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42053         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
42054         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42055         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42056         CVec_u8Z_free(ret_var);
42057         return ret_arr;
42058 }
42059
42060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42061         LDKHTLCOutputInCommitment this_obj_conv;
42062         this_obj_conv.inner = untag_ptr(this_obj);
42063         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42065         HTLCOutputInCommitment_free(this_obj_conv);
42066 }
42067
42068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
42069         LDKHTLCOutputInCommitment this_ptr_conv;
42070         this_ptr_conv.inner = untag_ptr(this_ptr);
42071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42073         this_ptr_conv.is_owned = false;
42074         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
42075         return ret_conv;
42076 }
42077
42078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42079         LDKHTLCOutputInCommitment this_ptr_conv;
42080         this_ptr_conv.inner = untag_ptr(this_ptr);
42081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42083         this_ptr_conv.is_owned = false;
42084         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
42085 }
42086
42087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42088         LDKHTLCOutputInCommitment this_ptr_conv;
42089         this_ptr_conv.inner = untag_ptr(this_ptr);
42090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42092         this_ptr_conv.is_owned = false;
42093         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
42094         return ret_conv;
42095 }
42096
42097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42098         LDKHTLCOutputInCommitment this_ptr_conv;
42099         this_ptr_conv.inner = untag_ptr(this_ptr);
42100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42102         this_ptr_conv.is_owned = false;
42103         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
42104 }
42105
42106 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
42107         LDKHTLCOutputInCommitment this_ptr_conv;
42108         this_ptr_conv.inner = untag_ptr(this_ptr);
42109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42111         this_ptr_conv.is_owned = false;
42112         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
42113         return ret_conv;
42114 }
42115
42116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42117         LDKHTLCOutputInCommitment this_ptr_conv;
42118         this_ptr_conv.inner = untag_ptr(this_ptr);
42119         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42121         this_ptr_conv.is_owned = false;
42122         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
42123 }
42124
42125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
42126         LDKHTLCOutputInCommitment this_ptr_conv;
42127         this_ptr_conv.inner = untag_ptr(this_ptr);
42128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42130         this_ptr_conv.is_owned = false;
42131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
42133         return ret_arr;
42134 }
42135
42136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42137         LDKHTLCOutputInCommitment this_ptr_conv;
42138         this_ptr_conv.inner = untag_ptr(this_ptr);
42139         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42141         this_ptr_conv.is_owned = false;
42142         LDKThirtyTwoBytes val_ref;
42143         CHECK((*env)->GetArrayLength(env, val) == 32);
42144         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42145         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
42146 }
42147
42148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
42149         LDKHTLCOutputInCommitment this_ptr_conv;
42150         this_ptr_conv.inner = untag_ptr(this_ptr);
42151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42153         this_ptr_conv.is_owned = false;
42154         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42155         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
42156         int64_t ret_ref = tag_ptr(ret_copy, true);
42157         return ret_ref;
42158 }
42159
42160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42161         LDKHTLCOutputInCommitment this_ptr_conv;
42162         this_ptr_conv.inner = untag_ptr(this_ptr);
42163         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42165         this_ptr_conv.is_owned = false;
42166         void* val_ptr = untag_ptr(val);
42167         CHECK_ACCESS(val_ptr);
42168         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
42169         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
42170         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
42171 }
42172
42173 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) {
42174         LDKThirtyTwoBytes payment_hash_arg_ref;
42175         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
42176         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
42177         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
42178         CHECK_ACCESS(transaction_output_index_arg_ptr);
42179         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
42180         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
42181         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
42182         int64_t ret_ref = 0;
42183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42185         return ret_ref;
42186 }
42187
42188 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
42189         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
42190         int64_t ret_ref = 0;
42191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42192         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42193         return ret_ref;
42194 }
42195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42196         LDKHTLCOutputInCommitment arg_conv;
42197         arg_conv.inner = untag_ptr(arg);
42198         arg_conv.is_owned = ptr_is_owned(arg);
42199         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42200         arg_conv.is_owned = false;
42201         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
42202         return ret_conv;
42203 }
42204
42205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42206         LDKHTLCOutputInCommitment orig_conv;
42207         orig_conv.inner = untag_ptr(orig);
42208         orig_conv.is_owned = ptr_is_owned(orig);
42209         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42210         orig_conv.is_owned = false;
42211         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
42212         int64_t ret_ref = 0;
42213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42215         return ret_ref;
42216 }
42217
42218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42219         LDKHTLCOutputInCommitment a_conv;
42220         a_conv.inner = untag_ptr(a);
42221         a_conv.is_owned = ptr_is_owned(a);
42222         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42223         a_conv.is_owned = false;
42224         LDKHTLCOutputInCommitment b_conv;
42225         b_conv.inner = untag_ptr(b);
42226         b_conv.is_owned = ptr_is_owned(b);
42227         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42228         b_conv.is_owned = false;
42229         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
42230         return ret_conv;
42231 }
42232
42233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
42234         LDKHTLCOutputInCommitment obj_conv;
42235         obj_conv.inner = untag_ptr(obj);
42236         obj_conv.is_owned = ptr_is_owned(obj);
42237         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42238         obj_conv.is_owned = false;
42239         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
42240         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42241         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42242         CVec_u8Z_free(ret_var);
42243         return ret_arr;
42244 }
42245
42246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42247         LDKu8slice ser_ref;
42248         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42249         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42250         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
42251         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
42252         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42253         return tag_ptr(ret_conv, true);
42254 }
42255
42256 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) {
42257         LDKHTLCOutputInCommitment htlc_conv;
42258         htlc_conv.inner = untag_ptr(htlc);
42259         htlc_conv.is_owned = ptr_is_owned(htlc);
42260         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
42261         htlc_conv.is_owned = false;
42262         LDKTxCreationKeys keys_conv;
42263         keys_conv.inner = untag_ptr(keys);
42264         keys_conv.is_owned = ptr_is_owned(keys);
42265         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
42266         keys_conv.is_owned = false;
42267         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
42268         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42269         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42270         CVec_u8Z_free(ret_var);
42271         return ret_arr;
42272 }
42273
42274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
42275         LDKPublicKey broadcaster_ref;
42276         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
42277         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
42278         LDKPublicKey countersignatory_ref;
42279         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
42280         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
42281         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
42282         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42283         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42284         CVec_u8Z_free(ret_var);
42285         return ret_arr;
42286 }
42287
42288 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) {
42289         unsigned char commitment_txid_arr[32];
42290         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
42291         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
42292         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
42293         LDKHTLCOutputInCommitment htlc_conv;
42294         htlc_conv.inner = untag_ptr(htlc);
42295         htlc_conv.is_owned = ptr_is_owned(htlc);
42296         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
42297         htlc_conv.is_owned = false;
42298         LDKPublicKey broadcaster_delayed_payment_key_ref;
42299         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42300         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42301         LDKPublicKey revocation_key_ref;
42302         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42303         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42304         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);
42305         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42306         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42307         Transaction_free(ret_var);
42308         return ret_arr;
42309 }
42310
42311 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) {
42312         LDKSignature local_sig_ref;
42313         CHECK((*env)->GetArrayLength(env, local_sig) == 64);
42314         (*env)->GetByteArrayRegion(env, local_sig, 0, 64, local_sig_ref.compact_form);
42315         LDKSignature remote_sig_ref;
42316         CHECK((*env)->GetArrayLength(env, remote_sig) == 64);
42317         (*env)->GetByteArrayRegion(env, remote_sig, 0, 64, remote_sig_ref.compact_form);
42318         LDKThirtyTwoBytes preimage_ref;
42319         CHECK((*env)->GetArrayLength(env, preimage) == 32);
42320         (*env)->GetByteArrayRegion(env, preimage, 0, 32, preimage_ref.data);
42321         LDKu8slice redeem_script_ref;
42322         redeem_script_ref.datalen = (*env)->GetArrayLength(env, redeem_script);
42323         redeem_script_ref.data = (*env)->GetByteArrayElements (env, redeem_script, NULL);
42324         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_ref, redeem_script_ref, opt_anchors);
42325         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42326         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42327         Witness_free(ret_var);
42328         (*env)->ReleaseByteArrayElements(env, redeem_script, (int8_t*)redeem_script_ref.data, 0);
42329         return ret_arr;
42330 }
42331
42332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1to_1countersignatory_1with_1anchors_1redeemscript(JNIEnv *env, jclass clz, int8_tArray payment_point) {
42333         LDKPublicKey payment_point_ref;
42334         CHECK((*env)->GetArrayLength(env, payment_point) == 33);
42335         (*env)->GetByteArrayRegion(env, payment_point, 0, 33, payment_point_ref.compressed_form);
42336         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
42337         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42338         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42339         CVec_u8Z_free(ret_var);
42340         return ret_arr;
42341 }
42342
42343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
42344         LDKPublicKey funding_pubkey_ref;
42345         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
42346         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
42347         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
42348         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42349         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42350         CVec_u8Z_free(ret_var);
42351         return ret_arr;
42352 }
42353
42354 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) {
42355         LDKPublicKey funding_key_ref;
42356         CHECK((*env)->GetArrayLength(env, funding_key) == 33);
42357         (*env)->GetByteArrayRegion(env, funding_key, 0, 33, funding_key_ref.compressed_form);
42358         LDKSignature funding_sig_ref;
42359         CHECK((*env)->GetArrayLength(env, funding_sig) == 64);
42360         (*env)->GetByteArrayRegion(env, funding_sig, 0, 64, funding_sig_ref.compact_form);
42361         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
42362         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42363         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42364         Witness_free(ret_var);
42365         return ret_arr;
42366 }
42367
42368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42369         LDKChannelTransactionParameters this_obj_conv;
42370         this_obj_conv.inner = untag_ptr(this_obj);
42371         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42373         ChannelTransactionParameters_free(this_obj_conv);
42374 }
42375
42376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
42377         LDKChannelTransactionParameters this_ptr_conv;
42378         this_ptr_conv.inner = untag_ptr(this_ptr);
42379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42381         this_ptr_conv.is_owned = false;
42382         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
42383         int64_t ret_ref = 0;
42384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42386         return ret_ref;
42387 }
42388
42389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42390         LDKChannelTransactionParameters this_ptr_conv;
42391         this_ptr_conv.inner = untag_ptr(this_ptr);
42392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42394         this_ptr_conv.is_owned = false;
42395         LDKChannelPublicKeys val_conv;
42396         val_conv.inner = untag_ptr(val);
42397         val_conv.is_owned = ptr_is_owned(val);
42398         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42399         val_conv = ChannelPublicKeys_clone(&val_conv);
42400         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
42401 }
42402
42403 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
42404         LDKChannelTransactionParameters this_ptr_conv;
42405         this_ptr_conv.inner = untag_ptr(this_ptr);
42406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42408         this_ptr_conv.is_owned = false;
42409         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
42410         return ret_conv;
42411 }
42412
42413 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) {
42414         LDKChannelTransactionParameters this_ptr_conv;
42415         this_ptr_conv.inner = untag_ptr(this_ptr);
42416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42418         this_ptr_conv.is_owned = false;
42419         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
42420 }
42421
42422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
42423         LDKChannelTransactionParameters this_ptr_conv;
42424         this_ptr_conv.inner = untag_ptr(this_ptr);
42425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42427         this_ptr_conv.is_owned = false;
42428         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
42429         return ret_conv;
42430 }
42431
42432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42433         LDKChannelTransactionParameters this_ptr_conv;
42434         this_ptr_conv.inner = untag_ptr(this_ptr);
42435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42437         this_ptr_conv.is_owned = false;
42438         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
42439 }
42440
42441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
42442         LDKChannelTransactionParameters this_ptr_conv;
42443         this_ptr_conv.inner = untag_ptr(this_ptr);
42444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42446         this_ptr_conv.is_owned = false;
42447         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
42448         int64_t ret_ref = 0;
42449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42451         return ret_ref;
42452 }
42453
42454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42455         LDKChannelTransactionParameters this_ptr_conv;
42456         this_ptr_conv.inner = untag_ptr(this_ptr);
42457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42459         this_ptr_conv.is_owned = false;
42460         LDKCounterpartyChannelTransactionParameters val_conv;
42461         val_conv.inner = untag_ptr(val);
42462         val_conv.is_owned = ptr_is_owned(val);
42463         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42464         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
42465         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
42466 }
42467
42468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42469         LDKChannelTransactionParameters this_ptr_conv;
42470         this_ptr_conv.inner = untag_ptr(this_ptr);
42471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42473         this_ptr_conv.is_owned = false;
42474         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
42475         int64_t ret_ref = 0;
42476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42478         return ret_ref;
42479 }
42480
42481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42482         LDKChannelTransactionParameters this_ptr_conv;
42483         this_ptr_conv.inner = untag_ptr(this_ptr);
42484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42486         this_ptr_conv.is_owned = false;
42487         LDKOutPoint val_conv;
42488         val_conv.inner = untag_ptr(val);
42489         val_conv.is_owned = ptr_is_owned(val);
42490         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42491         val_conv = OutPoint_clone(&val_conv);
42492         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
42493 }
42494
42495 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
42496         LDKChannelTransactionParameters this_ptr_conv;
42497         this_ptr_conv.inner = untag_ptr(this_ptr);
42498         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42500         this_ptr_conv.is_owned = false;
42501         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
42502         return ret_conv;
42503 }
42504
42505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
42506         LDKChannelTransactionParameters this_ptr_conv;
42507         this_ptr_conv.inner = untag_ptr(this_ptr);
42508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42510         this_ptr_conv.is_owned = false;
42511         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
42512         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
42513 }
42514
42515 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1non_1zero_1fee_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
42516         LDKChannelTransactionParameters this_ptr_conv;
42517         this_ptr_conv.inner = untag_ptr(this_ptr);
42518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42520         this_ptr_conv.is_owned = false;
42521         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_non_zero_fee_anchors(&this_ptr_conv));
42522         return ret_conv;
42523 }
42524
42525 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) {
42526         LDKChannelTransactionParameters this_ptr_conv;
42527         this_ptr_conv.inner = untag_ptr(this_ptr);
42528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42530         this_ptr_conv.is_owned = false;
42531         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
42532         ChannelTransactionParameters_set_opt_non_zero_fee_anchors(&this_ptr_conv, val_conv);
42533 }
42534
42535 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) {
42536         LDKChannelPublicKeys holder_pubkeys_arg_conv;
42537         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
42538         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
42539         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
42540         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
42541         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
42542         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
42543         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
42544         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
42545         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
42546         LDKOutPoint funding_outpoint_arg_conv;
42547         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
42548         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
42549         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
42550         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
42551         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
42552         LDKCOption_NoneZ opt_non_zero_fee_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_non_zero_fee_anchors_arg);
42553         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);
42554         int64_t ret_ref = 0;
42555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42557         return ret_ref;
42558 }
42559
42560 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
42561         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
42562         int64_t ret_ref = 0;
42563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42564         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42565         return ret_ref;
42566 }
42567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42568         LDKChannelTransactionParameters arg_conv;
42569         arg_conv.inner = untag_ptr(arg);
42570         arg_conv.is_owned = ptr_is_owned(arg);
42571         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42572         arg_conv.is_owned = false;
42573         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
42574         return ret_conv;
42575 }
42576
42577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42578         LDKChannelTransactionParameters orig_conv;
42579         orig_conv.inner = untag_ptr(orig);
42580         orig_conv.is_owned = ptr_is_owned(orig);
42581         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42582         orig_conv.is_owned = false;
42583         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
42584         int64_t ret_ref = 0;
42585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42587         return ret_ref;
42588 }
42589
42590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42591         LDKCounterpartyChannelTransactionParameters this_obj_conv;
42592         this_obj_conv.inner = untag_ptr(this_obj);
42593         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42595         CounterpartyChannelTransactionParameters_free(this_obj_conv);
42596 }
42597
42598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
42599         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42600         this_ptr_conv.inner = untag_ptr(this_ptr);
42601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42603         this_ptr_conv.is_owned = false;
42604         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
42605         int64_t ret_ref = 0;
42606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42608         return ret_ref;
42609 }
42610
42611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42612         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42613         this_ptr_conv.inner = untag_ptr(this_ptr);
42614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42616         this_ptr_conv.is_owned = false;
42617         LDKChannelPublicKeys val_conv;
42618         val_conv.inner = untag_ptr(val);
42619         val_conv.is_owned = ptr_is_owned(val);
42620         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42621         val_conv = ChannelPublicKeys_clone(&val_conv);
42622         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
42623 }
42624
42625 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
42626         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42627         this_ptr_conv.inner = untag_ptr(this_ptr);
42628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42630         this_ptr_conv.is_owned = false;
42631         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
42632         return ret_conv;
42633 }
42634
42635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42636         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42637         this_ptr_conv.inner = untag_ptr(this_ptr);
42638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42640         this_ptr_conv.is_owned = false;
42641         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
42642 }
42643
42644 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) {
42645         LDKChannelPublicKeys pubkeys_arg_conv;
42646         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
42647         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
42648         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
42649         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
42650         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
42651         int64_t ret_ref = 0;
42652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42654         return ret_ref;
42655 }
42656
42657 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
42658         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
42659         int64_t ret_ref = 0;
42660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42661         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42662         return ret_ref;
42663 }
42664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42665         LDKCounterpartyChannelTransactionParameters arg_conv;
42666         arg_conv.inner = untag_ptr(arg);
42667         arg_conv.is_owned = ptr_is_owned(arg);
42668         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42669         arg_conv.is_owned = false;
42670         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
42671         return ret_conv;
42672 }
42673
42674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42675         LDKCounterpartyChannelTransactionParameters orig_conv;
42676         orig_conv.inner = untag_ptr(orig);
42677         orig_conv.is_owned = ptr_is_owned(orig);
42678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42679         orig_conv.is_owned = false;
42680         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
42681         int64_t ret_ref = 0;
42682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42684         return ret_ref;
42685 }
42686
42687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
42688         LDKChannelTransactionParameters this_arg_conv;
42689         this_arg_conv.inner = untag_ptr(this_arg);
42690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42692         this_arg_conv.is_owned = false;
42693         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
42694         return ret_conv;
42695 }
42696
42697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
42698         LDKChannelTransactionParameters this_arg_conv;
42699         this_arg_conv.inner = untag_ptr(this_arg);
42700         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42702         this_arg_conv.is_owned = false;
42703         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
42704         int64_t ret_ref = 0;
42705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42707         return ret_ref;
42708 }
42709
42710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
42711         LDKChannelTransactionParameters this_arg_conv;
42712         this_arg_conv.inner = untag_ptr(this_arg);
42713         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42715         this_arg_conv.is_owned = false;
42716         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
42717         int64_t ret_ref = 0;
42718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42720         return ret_ref;
42721 }
42722
42723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42724         LDKCounterpartyChannelTransactionParameters obj_conv;
42725         obj_conv.inner = untag_ptr(obj);
42726         obj_conv.is_owned = ptr_is_owned(obj);
42727         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42728         obj_conv.is_owned = false;
42729         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
42730         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42731         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42732         CVec_u8Z_free(ret_var);
42733         return ret_arr;
42734 }
42735
42736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42737         LDKu8slice ser_ref;
42738         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42739         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42740         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
42741         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
42742         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42743         return tag_ptr(ret_conv, true);
42744 }
42745
42746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42747         LDKChannelTransactionParameters obj_conv;
42748         obj_conv.inner = untag_ptr(obj);
42749         obj_conv.is_owned = ptr_is_owned(obj);
42750         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42751         obj_conv.is_owned = false;
42752         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
42753         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42754         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42755         CVec_u8Z_free(ret_var);
42756         return ret_arr;
42757 }
42758
42759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42760         LDKu8slice ser_ref;
42761         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42762         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42763         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
42764         *ret_conv = ChannelTransactionParameters_read(ser_ref);
42765         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42766         return tag_ptr(ret_conv, true);
42767 }
42768
42769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42770         LDKDirectedChannelTransactionParameters this_obj_conv;
42771         this_obj_conv.inner = untag_ptr(this_obj);
42772         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42774         DirectedChannelTransactionParameters_free(this_obj_conv);
42775 }
42776
42777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
42778         LDKDirectedChannelTransactionParameters this_arg_conv;
42779         this_arg_conv.inner = untag_ptr(this_arg);
42780         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42782         this_arg_conv.is_owned = false;
42783         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
42784         int64_t ret_ref = 0;
42785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42787         return ret_ref;
42788 }
42789
42790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
42791         LDKDirectedChannelTransactionParameters this_arg_conv;
42792         this_arg_conv.inner = untag_ptr(this_arg);
42793         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42795         this_arg_conv.is_owned = false;
42796         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
42797         int64_t ret_ref = 0;
42798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42799         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42800         return ret_ref;
42801 }
42802
42803 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
42804         LDKDirectedChannelTransactionParameters this_arg_conv;
42805         this_arg_conv.inner = untag_ptr(this_arg);
42806         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42808         this_arg_conv.is_owned = false;
42809         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
42810         return ret_conv;
42811 }
42812
42813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
42814         LDKDirectedChannelTransactionParameters this_arg_conv;
42815         this_arg_conv.inner = untag_ptr(this_arg);
42816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42818         this_arg_conv.is_owned = false;
42819         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
42820         return ret_conv;
42821 }
42822
42823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
42824         LDKDirectedChannelTransactionParameters this_arg_conv;
42825         this_arg_conv.inner = untag_ptr(this_arg);
42826         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42828         this_arg_conv.is_owned = false;
42829         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
42830         int64_t ret_ref = 0;
42831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42833         return ret_ref;
42834 }
42835
42836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
42837         LDKDirectedChannelTransactionParameters this_arg_conv;
42838         this_arg_conv.inner = untag_ptr(this_arg);
42839         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42841         this_arg_conv.is_owned = false;
42842         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
42843         return ret_conv;
42844 }
42845
42846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42847         LDKHolderCommitmentTransaction this_obj_conv;
42848         this_obj_conv.inner = untag_ptr(this_obj);
42849         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42851         HolderCommitmentTransaction_free(this_obj_conv);
42852 }
42853
42854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
42855         LDKHolderCommitmentTransaction this_ptr_conv;
42856         this_ptr_conv.inner = untag_ptr(this_ptr);
42857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42859         this_ptr_conv.is_owned = false;
42860         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
42861         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
42862         return ret_arr;
42863 }
42864
42865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42866         LDKHolderCommitmentTransaction this_ptr_conv;
42867         this_ptr_conv.inner = untag_ptr(this_ptr);
42868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42870         this_ptr_conv.is_owned = false;
42871         LDKSignature val_ref;
42872         CHECK((*env)->GetArrayLength(env, val) == 64);
42873         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
42874         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
42875 }
42876
42877 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
42878         LDKHolderCommitmentTransaction this_ptr_conv;
42879         this_ptr_conv.inner = untag_ptr(this_ptr);
42880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42882         this_ptr_conv.is_owned = false;
42883         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
42884         jobjectArray ret_arr = NULL;
42885         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
42886         ;
42887         for (size_t i = 0; i < ret_var.datalen; i++) {
42888                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
42889                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
42890                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
42891         }
42892         
42893         FREE(ret_var.data);
42894         return ret_arr;
42895 }
42896
42897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
42898         LDKHolderCommitmentTransaction this_ptr_conv;
42899         this_ptr_conv.inner = untag_ptr(this_ptr);
42900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42902         this_ptr_conv.is_owned = false;
42903         LDKCVec_SignatureZ val_constr;
42904         val_constr.datalen = (*env)->GetArrayLength(env, val);
42905         if (val_constr.datalen > 0)
42906                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
42907         else
42908                 val_constr.data = NULL;
42909         for (size_t i = 0; i < val_constr.datalen; i++) {
42910                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
42911                 LDKSignature val_conv_8_ref;
42912                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
42913                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
42914                 val_constr.data[i] = val_conv_8_ref;
42915         }
42916         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
42917 }
42918
42919 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
42920         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
42921         int64_t ret_ref = 0;
42922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42924         return ret_ref;
42925 }
42926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42927         LDKHolderCommitmentTransaction arg_conv;
42928         arg_conv.inner = untag_ptr(arg);
42929         arg_conv.is_owned = ptr_is_owned(arg);
42930         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42931         arg_conv.is_owned = false;
42932         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
42933         return ret_conv;
42934 }
42935
42936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42937         LDKHolderCommitmentTransaction orig_conv;
42938         orig_conv.inner = untag_ptr(orig);
42939         orig_conv.is_owned = ptr_is_owned(orig);
42940         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42941         orig_conv.is_owned = false;
42942         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
42943         int64_t ret_ref = 0;
42944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42945         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42946         return ret_ref;
42947 }
42948
42949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
42950         LDKHolderCommitmentTransaction obj_conv;
42951         obj_conv.inner = untag_ptr(obj);
42952         obj_conv.is_owned = ptr_is_owned(obj);
42953         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42954         obj_conv.is_owned = false;
42955         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
42956         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42957         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42958         CVec_u8Z_free(ret_var);
42959         return ret_arr;
42960 }
42961
42962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42963         LDKu8slice ser_ref;
42964         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42965         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42966         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
42967         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
42968         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42969         return tag_ptr(ret_conv, true);
42970 }
42971
42972 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) {
42973         LDKCommitmentTransaction commitment_tx_conv;
42974         commitment_tx_conv.inner = untag_ptr(commitment_tx);
42975         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
42976         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
42977         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
42978         LDKSignature counterparty_sig_ref;
42979         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
42980         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
42981         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
42982         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
42983         if (counterparty_htlc_sigs_constr.datalen > 0)
42984                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
42985         else
42986                 counterparty_htlc_sigs_constr.data = NULL;
42987         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
42988                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
42989                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
42990                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
42991                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
42992                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
42993         }
42994         LDKPublicKey holder_funding_key_ref;
42995         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
42996         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
42997         LDKPublicKey counterparty_funding_key_ref;
42998         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
42999         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
43000         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
43001         int64_t ret_ref = 0;
43002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43004         return ret_ref;
43005 }
43006
43007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43008         LDKBuiltCommitmentTransaction this_obj_conv;
43009         this_obj_conv.inner = untag_ptr(this_obj);
43010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43012         BuiltCommitmentTransaction_free(this_obj_conv);
43013 }
43014
43015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
43016         LDKBuiltCommitmentTransaction this_ptr_conv;
43017         this_ptr_conv.inner = untag_ptr(this_ptr);
43018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43020         this_ptr_conv.is_owned = false;
43021         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
43022         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43023         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43024         Transaction_free(ret_var);
43025         return ret_arr;
43026 }
43027
43028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43029         LDKBuiltCommitmentTransaction this_ptr_conv;
43030         this_ptr_conv.inner = untag_ptr(this_ptr);
43031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43033         this_ptr_conv.is_owned = false;
43034         LDKTransaction val_ref;
43035         val_ref.datalen = (*env)->GetArrayLength(env, val);
43036         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
43037         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43038         val_ref.data_is_owned = true;
43039         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
43040 }
43041
43042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
43043         LDKBuiltCommitmentTransaction this_ptr_conv;
43044         this_ptr_conv.inner = untag_ptr(this_ptr);
43045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43047         this_ptr_conv.is_owned = false;
43048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
43050         return ret_arr;
43051 }
43052
43053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43054         LDKBuiltCommitmentTransaction this_ptr_conv;
43055         this_ptr_conv.inner = untag_ptr(this_ptr);
43056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43058         this_ptr_conv.is_owned = false;
43059         LDKThirtyTwoBytes val_ref;
43060         CHECK((*env)->GetArrayLength(env, val) == 32);
43061         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43062         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
43063 }
43064
43065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
43066         LDKTransaction transaction_arg_ref;
43067         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
43068         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
43069         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
43070         transaction_arg_ref.data_is_owned = true;
43071         LDKThirtyTwoBytes txid_arg_ref;
43072         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
43073         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
43074         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
43075         int64_t ret_ref = 0;
43076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43078         return ret_ref;
43079 }
43080
43081 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
43082         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
43083         int64_t ret_ref = 0;
43084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43086         return ret_ref;
43087 }
43088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43089         LDKBuiltCommitmentTransaction arg_conv;
43090         arg_conv.inner = untag_ptr(arg);
43091         arg_conv.is_owned = ptr_is_owned(arg);
43092         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43093         arg_conv.is_owned = false;
43094         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
43095         return ret_conv;
43096 }
43097
43098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43099         LDKBuiltCommitmentTransaction orig_conv;
43100         orig_conv.inner = untag_ptr(orig);
43101         orig_conv.is_owned = ptr_is_owned(orig);
43102         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43103         orig_conv.is_owned = false;
43104         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
43105         int64_t ret_ref = 0;
43106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43107         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43108         return ret_ref;
43109 }
43110
43111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43112         LDKBuiltCommitmentTransaction obj_conv;
43113         obj_conv.inner = untag_ptr(obj);
43114         obj_conv.is_owned = ptr_is_owned(obj);
43115         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43116         obj_conv.is_owned = false;
43117         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
43118         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43119         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43120         CVec_u8Z_free(ret_var);
43121         return ret_arr;
43122 }
43123
43124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43125         LDKu8slice ser_ref;
43126         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43127         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43128         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
43129         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
43130         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43131         return tag_ptr(ret_conv, true);
43132 }
43133
43134 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) {
43135         LDKBuiltCommitmentTransaction this_arg_conv;
43136         this_arg_conv.inner = untag_ptr(this_arg);
43137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43139         this_arg_conv.is_owned = false;
43140         LDKu8slice funding_redeemscript_ref;
43141         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43142         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43143         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43144         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
43145         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43146         return ret_arr;
43147 }
43148
43149 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) {
43150         LDKBuiltCommitmentTransaction this_arg_conv;
43151         this_arg_conv.inner = untag_ptr(this_arg);
43152         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43154         this_arg_conv.is_owned = false;
43155         unsigned char funding_key_arr[32];
43156         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
43157         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
43158         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
43159         LDKu8slice funding_redeemscript_ref;
43160         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43161         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43162         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
43164         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43165         return ret_arr;
43166 }
43167
43168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43169         LDKClosingTransaction this_obj_conv;
43170         this_obj_conv.inner = untag_ptr(this_obj);
43171         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43173         ClosingTransaction_free(this_obj_conv);
43174 }
43175
43176 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
43177         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
43178         int64_t ret_ref = 0;
43179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43181         return ret_ref;
43182 }
43183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43184         LDKClosingTransaction arg_conv;
43185         arg_conv.inner = untag_ptr(arg);
43186         arg_conv.is_owned = ptr_is_owned(arg);
43187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43188         arg_conv.is_owned = false;
43189         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
43190         return ret_conv;
43191 }
43192
43193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43194         LDKClosingTransaction orig_conv;
43195         orig_conv.inner = untag_ptr(orig);
43196         orig_conv.is_owned = ptr_is_owned(orig);
43197         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43198         orig_conv.is_owned = false;
43199         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
43200         int64_t ret_ref = 0;
43201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43203         return ret_ref;
43204 }
43205
43206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
43207         LDKClosingTransaction o_conv;
43208         o_conv.inner = untag_ptr(o);
43209         o_conv.is_owned = ptr_is_owned(o);
43210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43211         o_conv.is_owned = false;
43212         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
43213         return ret_conv;
43214 }
43215
43216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43217         LDKClosingTransaction a_conv;
43218         a_conv.inner = untag_ptr(a);
43219         a_conv.is_owned = ptr_is_owned(a);
43220         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43221         a_conv.is_owned = false;
43222         LDKClosingTransaction b_conv;
43223         b_conv.inner = untag_ptr(b);
43224         b_conv.is_owned = ptr_is_owned(b);
43225         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43226         b_conv.is_owned = false;
43227         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
43228         return ret_conv;
43229 }
43230
43231 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) {
43232         LDKCVec_u8Z to_holder_script_ref;
43233         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
43234         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
43235         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
43236         LDKCVec_u8Z to_counterparty_script_ref;
43237         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
43238         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
43239         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
43240         LDKOutPoint funding_outpoint_conv;
43241         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
43242         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
43243         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
43244         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
43245         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
43246         int64_t ret_ref = 0;
43247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43249         return ret_ref;
43250 }
43251
43252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
43253         LDKClosingTransaction this_arg_conv;
43254         this_arg_conv.inner = untag_ptr(this_arg);
43255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43257         this_arg_conv.is_owned = false;
43258         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
43259         int64_t ret_ref = 0;
43260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43262         return ret_ref;
43263 }
43264
43265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
43266         LDKClosingTransaction this_arg_conv;
43267         this_arg_conv.inner = untag_ptr(this_arg);
43268         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43270         this_arg_conv.is_owned = false;
43271         LDKOutPoint funding_outpoint_conv;
43272         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
43273         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
43274         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
43275         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
43276         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
43277         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
43278         return tag_ptr(ret_conv, true);
43279 }
43280
43281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43282         LDKClosingTransaction this_arg_conv;
43283         this_arg_conv.inner = untag_ptr(this_arg);
43284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43286         this_arg_conv.is_owned = false;
43287         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
43288         return ret_conv;
43289 }
43290
43291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43292         LDKClosingTransaction this_arg_conv;
43293         this_arg_conv.inner = untag_ptr(this_arg);
43294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43296         this_arg_conv.is_owned = false;
43297         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
43298         return ret_conv;
43299 }
43300
43301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43302         LDKClosingTransaction this_arg_conv;
43303         this_arg_conv.inner = untag_ptr(this_arg);
43304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43306         this_arg_conv.is_owned = false;
43307         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
43308         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43309         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43310         return ret_arr;
43311 }
43312
43313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43314         LDKClosingTransaction this_arg_conv;
43315         this_arg_conv.inner = untag_ptr(this_arg);
43316         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43318         this_arg_conv.is_owned = false;
43319         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
43320         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43321         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43322         return ret_arr;
43323 }
43324
43325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43326         LDKTrustedClosingTransaction this_obj_conv;
43327         this_obj_conv.inner = untag_ptr(this_obj);
43328         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43330         TrustedClosingTransaction_free(this_obj_conv);
43331 }
43332
43333 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
43334         LDKTrustedClosingTransaction this_arg_conv;
43335         this_arg_conv.inner = untag_ptr(this_arg);
43336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43338         this_arg_conv.is_owned = false;
43339         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
43340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43342         Transaction_free(ret_var);
43343         return ret_arr;
43344 }
43345
43346 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) {
43347         LDKTrustedClosingTransaction this_arg_conv;
43348         this_arg_conv.inner = untag_ptr(this_arg);
43349         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43351         this_arg_conv.is_owned = false;
43352         LDKu8slice funding_redeemscript_ref;
43353         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43354         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43355         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43356         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
43357         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43358         return ret_arr;
43359 }
43360
43361 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) {
43362         LDKTrustedClosingTransaction this_arg_conv;
43363         this_arg_conv.inner = untag_ptr(this_arg);
43364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43366         this_arg_conv.is_owned = false;
43367         unsigned char funding_key_arr[32];
43368         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
43369         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
43370         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
43371         LDKu8slice funding_redeemscript_ref;
43372         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43373         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43374         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43375         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
43376         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43377         return ret_arr;
43378 }
43379
43380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43381         LDKCommitmentTransaction this_obj_conv;
43382         this_obj_conv.inner = untag_ptr(this_obj);
43383         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43385         CommitmentTransaction_free(this_obj_conv);
43386 }
43387
43388 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
43389         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
43390         int64_t ret_ref = 0;
43391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43393         return ret_ref;
43394 }
43395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43396         LDKCommitmentTransaction arg_conv;
43397         arg_conv.inner = untag_ptr(arg);
43398         arg_conv.is_owned = ptr_is_owned(arg);
43399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43400         arg_conv.is_owned = false;
43401         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
43402         return ret_conv;
43403 }
43404
43405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43406         LDKCommitmentTransaction orig_conv;
43407         orig_conv.inner = untag_ptr(orig);
43408         orig_conv.is_owned = ptr_is_owned(orig);
43409         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43410         orig_conv.is_owned = false;
43411         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
43412         int64_t ret_ref = 0;
43413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43415         return ret_ref;
43416 }
43417
43418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43419         LDKCommitmentTransaction obj_conv;
43420         obj_conv.inner = untag_ptr(obj);
43421         obj_conv.is_owned = ptr_is_owned(obj);
43422         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43423         obj_conv.is_owned = false;
43424         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
43425         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43426         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43427         CVec_u8Z_free(ret_var);
43428         return ret_arr;
43429 }
43430
43431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43432         LDKu8slice ser_ref;
43433         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43434         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43435         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
43436         *ret_conv = CommitmentTransaction_read(ser_ref);
43437         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43438         return tag_ptr(ret_conv, true);
43439 }
43440
43441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
43442         LDKCommitmentTransaction this_arg_conv;
43443         this_arg_conv.inner = untag_ptr(this_arg);
43444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43446         this_arg_conv.is_owned = false;
43447         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
43448         return ret_conv;
43449 }
43450
43451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43452         LDKCommitmentTransaction this_arg_conv;
43453         this_arg_conv.inner = untag_ptr(this_arg);
43454         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43456         this_arg_conv.is_owned = false;
43457         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
43458         return ret_conv;
43459 }
43460
43461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43462         LDKCommitmentTransaction this_arg_conv;
43463         this_arg_conv.inner = untag_ptr(this_arg);
43464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43466         this_arg_conv.is_owned = false;
43467         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
43468         return ret_conv;
43469 }
43470
43471 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
43472         LDKCommitmentTransaction this_arg_conv;
43473         this_arg_conv.inner = untag_ptr(this_arg);
43474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43476         this_arg_conv.is_owned = false;
43477         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
43478         return ret_conv;
43479 }
43480
43481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
43482         LDKCommitmentTransaction this_arg_conv;
43483         this_arg_conv.inner = untag_ptr(this_arg);
43484         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43486         this_arg_conv.is_owned = false;
43487         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
43488         int64_t ret_ref = 0;
43489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43491         return ret_ref;
43492 }
43493
43494 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) {
43495         LDKCommitmentTransaction this_arg_conv;
43496         this_arg_conv.inner = untag_ptr(this_arg);
43497         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43499         this_arg_conv.is_owned = false;
43500         LDKDirectedChannelTransactionParameters channel_parameters_conv;
43501         channel_parameters_conv.inner = untag_ptr(channel_parameters);
43502         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
43503         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
43504         channel_parameters_conv.is_owned = false;
43505         LDKChannelPublicKeys broadcaster_keys_conv;
43506         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
43507         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
43508         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
43509         broadcaster_keys_conv.is_owned = false;
43510         LDKChannelPublicKeys countersignatory_keys_conv;
43511         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
43512         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
43513         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
43514         countersignatory_keys_conv.is_owned = false;
43515         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
43516         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
43517         return tag_ptr(ret_conv, true);
43518 }
43519
43520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43521         LDKTrustedCommitmentTransaction this_obj_conv;
43522         this_obj_conv.inner = untag_ptr(this_obj);
43523         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43525         TrustedCommitmentTransaction_free(this_obj_conv);
43526 }
43527
43528 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
43529         LDKTrustedCommitmentTransaction this_arg_conv;
43530         this_arg_conv.inner = untag_ptr(this_arg);
43531         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43533         this_arg_conv.is_owned = false;
43534         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43535         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
43536         return ret_arr;
43537 }
43538
43539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
43540         LDKTrustedCommitmentTransaction this_arg_conv;
43541         this_arg_conv.inner = untag_ptr(this_arg);
43542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43544         this_arg_conv.is_owned = false;
43545         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
43546         int64_t ret_ref = 0;
43547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43548         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43549         return ret_ref;
43550 }
43551
43552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
43553         LDKTrustedCommitmentTransaction this_arg_conv;
43554         this_arg_conv.inner = untag_ptr(this_arg);
43555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43557         this_arg_conv.is_owned = false;
43558         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
43559         int64_t ret_ref = 0;
43560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43562         return ret_ref;
43563 }
43564
43565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
43566         LDKTrustedCommitmentTransaction this_arg_conv;
43567         this_arg_conv.inner = untag_ptr(this_arg);
43568         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43570         this_arg_conv.is_owned = false;
43571         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
43572         return ret_conv;
43573 }
43574
43575 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) {
43576         LDKTrustedCommitmentTransaction this_arg_conv;
43577         this_arg_conv.inner = untag_ptr(this_arg);
43578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43580         this_arg_conv.is_owned = false;
43581         unsigned char htlc_base_key_arr[32];
43582         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
43583         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
43584         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
43585         LDKDirectedChannelTransactionParameters channel_parameters_conv;
43586         channel_parameters_conv.inner = untag_ptr(channel_parameters);
43587         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
43588         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
43589         channel_parameters_conv.is_owned = false;
43590         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
43591         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
43592         return tag_ptr(ret_conv, true);
43593 }
43594
43595 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) {
43596         LDKPublicKey broadcaster_payment_basepoint_ref;
43597         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
43598         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
43599         LDKPublicKey countersignatory_payment_basepoint_ref;
43600         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
43601         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
43602         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
43603         return ret_conv;
43604 }
43605
43606 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43607         LDKInitFeatures a_conv;
43608         a_conv.inner = untag_ptr(a);
43609         a_conv.is_owned = ptr_is_owned(a);
43610         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43611         a_conv.is_owned = false;
43612         LDKInitFeatures b_conv;
43613         b_conv.inner = untag_ptr(b);
43614         b_conv.is_owned = ptr_is_owned(b);
43615         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43616         b_conv.is_owned = false;
43617         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
43618         return ret_conv;
43619 }
43620
43621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43622         LDKNodeFeatures a_conv;
43623         a_conv.inner = untag_ptr(a);
43624         a_conv.is_owned = ptr_is_owned(a);
43625         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43626         a_conv.is_owned = false;
43627         LDKNodeFeatures b_conv;
43628         b_conv.inner = untag_ptr(b);
43629         b_conv.is_owned = ptr_is_owned(b);
43630         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43631         b_conv.is_owned = false;
43632         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
43633         return ret_conv;
43634 }
43635
43636 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43637         LDKChannelFeatures a_conv;
43638         a_conv.inner = untag_ptr(a);
43639         a_conv.is_owned = ptr_is_owned(a);
43640         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43641         a_conv.is_owned = false;
43642         LDKChannelFeatures b_conv;
43643         b_conv.inner = untag_ptr(b);
43644         b_conv.is_owned = ptr_is_owned(b);
43645         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43646         b_conv.is_owned = false;
43647         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
43648         return ret_conv;
43649 }
43650
43651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43652         LDKInvoiceFeatures a_conv;
43653         a_conv.inner = untag_ptr(a);
43654         a_conv.is_owned = ptr_is_owned(a);
43655         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43656         a_conv.is_owned = false;
43657         LDKInvoiceFeatures b_conv;
43658         b_conv.inner = untag_ptr(b);
43659         b_conv.is_owned = ptr_is_owned(b);
43660         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43661         b_conv.is_owned = false;
43662         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
43663         return ret_conv;
43664 }
43665
43666 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43667         LDKOfferFeatures a_conv;
43668         a_conv.inner = untag_ptr(a);
43669         a_conv.is_owned = ptr_is_owned(a);
43670         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43671         a_conv.is_owned = false;
43672         LDKOfferFeatures b_conv;
43673         b_conv.inner = untag_ptr(b);
43674         b_conv.is_owned = ptr_is_owned(b);
43675         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43676         b_conv.is_owned = false;
43677         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
43678         return ret_conv;
43679 }
43680
43681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43682         LDKInvoiceRequestFeatures a_conv;
43683         a_conv.inner = untag_ptr(a);
43684         a_conv.is_owned = ptr_is_owned(a);
43685         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43686         a_conv.is_owned = false;
43687         LDKInvoiceRequestFeatures b_conv;
43688         b_conv.inner = untag_ptr(b);
43689         b_conv.is_owned = ptr_is_owned(b);
43690         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43691         b_conv.is_owned = false;
43692         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
43693         return ret_conv;
43694 }
43695
43696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43697         LDKChannelTypeFeatures a_conv;
43698         a_conv.inner = untag_ptr(a);
43699         a_conv.is_owned = ptr_is_owned(a);
43700         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43701         a_conv.is_owned = false;
43702         LDKChannelTypeFeatures b_conv;
43703         b_conv.inner = untag_ptr(b);
43704         b_conv.is_owned = ptr_is_owned(b);
43705         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43706         b_conv.is_owned = false;
43707         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
43708         return ret_conv;
43709 }
43710
43711 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
43712         LDKInitFeatures ret_var = InitFeatures_clone(arg);
43713         int64_t ret_ref = 0;
43714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43716         return ret_ref;
43717 }
43718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43719         LDKInitFeatures arg_conv;
43720         arg_conv.inner = untag_ptr(arg);
43721         arg_conv.is_owned = ptr_is_owned(arg);
43722         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43723         arg_conv.is_owned = false;
43724         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
43725         return ret_conv;
43726 }
43727
43728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43729         LDKInitFeatures orig_conv;
43730         orig_conv.inner = untag_ptr(orig);
43731         orig_conv.is_owned = ptr_is_owned(orig);
43732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43733         orig_conv.is_owned = false;
43734         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
43735         int64_t ret_ref = 0;
43736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43738         return ret_ref;
43739 }
43740
43741 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
43742         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
43743         int64_t ret_ref = 0;
43744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43746         return ret_ref;
43747 }
43748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43749         LDKNodeFeatures arg_conv;
43750         arg_conv.inner = untag_ptr(arg);
43751         arg_conv.is_owned = ptr_is_owned(arg);
43752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43753         arg_conv.is_owned = false;
43754         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
43755         return ret_conv;
43756 }
43757
43758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43759         LDKNodeFeatures orig_conv;
43760         orig_conv.inner = untag_ptr(orig);
43761         orig_conv.is_owned = ptr_is_owned(orig);
43762         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43763         orig_conv.is_owned = false;
43764         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
43765         int64_t ret_ref = 0;
43766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43768         return ret_ref;
43769 }
43770
43771 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
43772         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
43773         int64_t ret_ref = 0;
43774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43776         return ret_ref;
43777 }
43778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43779         LDKChannelFeatures arg_conv;
43780         arg_conv.inner = untag_ptr(arg);
43781         arg_conv.is_owned = ptr_is_owned(arg);
43782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43783         arg_conv.is_owned = false;
43784         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
43785         return ret_conv;
43786 }
43787
43788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43789         LDKChannelFeatures orig_conv;
43790         orig_conv.inner = untag_ptr(orig);
43791         orig_conv.is_owned = ptr_is_owned(orig);
43792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43793         orig_conv.is_owned = false;
43794         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
43795         int64_t ret_ref = 0;
43796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43798         return ret_ref;
43799 }
43800
43801 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
43802         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
43803         int64_t ret_ref = 0;
43804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43806         return ret_ref;
43807 }
43808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43809         LDKInvoiceFeatures arg_conv;
43810         arg_conv.inner = untag_ptr(arg);
43811         arg_conv.is_owned = ptr_is_owned(arg);
43812         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43813         arg_conv.is_owned = false;
43814         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
43815         return ret_conv;
43816 }
43817
43818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43819         LDKInvoiceFeatures orig_conv;
43820         orig_conv.inner = untag_ptr(orig);
43821         orig_conv.is_owned = ptr_is_owned(orig);
43822         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43823         orig_conv.is_owned = false;
43824         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
43825         int64_t ret_ref = 0;
43826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43828         return ret_ref;
43829 }
43830
43831 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
43832         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
43833         int64_t ret_ref = 0;
43834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43836         return ret_ref;
43837 }
43838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43839         LDKOfferFeatures arg_conv;
43840         arg_conv.inner = untag_ptr(arg);
43841         arg_conv.is_owned = ptr_is_owned(arg);
43842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43843         arg_conv.is_owned = false;
43844         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
43845         return ret_conv;
43846 }
43847
43848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43849         LDKOfferFeatures orig_conv;
43850         orig_conv.inner = untag_ptr(orig);
43851         orig_conv.is_owned = ptr_is_owned(orig);
43852         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43853         orig_conv.is_owned = false;
43854         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
43855         int64_t ret_ref = 0;
43856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43858         return ret_ref;
43859 }
43860
43861 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
43862         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
43863         int64_t ret_ref = 0;
43864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43866         return ret_ref;
43867 }
43868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43869         LDKInvoiceRequestFeatures arg_conv;
43870         arg_conv.inner = untag_ptr(arg);
43871         arg_conv.is_owned = ptr_is_owned(arg);
43872         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43873         arg_conv.is_owned = false;
43874         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
43875         return ret_conv;
43876 }
43877
43878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43879         LDKInvoiceRequestFeatures orig_conv;
43880         orig_conv.inner = untag_ptr(orig);
43881         orig_conv.is_owned = ptr_is_owned(orig);
43882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43883         orig_conv.is_owned = false;
43884         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
43885         int64_t ret_ref = 0;
43886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43888         return ret_ref;
43889 }
43890
43891 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
43892         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
43893         int64_t ret_ref = 0;
43894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43896         return ret_ref;
43897 }
43898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43899         LDKChannelTypeFeatures arg_conv;
43900         arg_conv.inner = untag_ptr(arg);
43901         arg_conv.is_owned = ptr_is_owned(arg);
43902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43903         arg_conv.is_owned = false;
43904         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
43905         return ret_conv;
43906 }
43907
43908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43909         LDKChannelTypeFeatures orig_conv;
43910         orig_conv.inner = untag_ptr(orig);
43911         orig_conv.is_owned = ptr_is_owned(orig);
43912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43913         orig_conv.is_owned = false;
43914         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
43915         int64_t ret_ref = 0;
43916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43918         return ret_ref;
43919 }
43920
43921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43922         LDKInitFeatures this_obj_conv;
43923         this_obj_conv.inner = untag_ptr(this_obj);
43924         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43926         InitFeatures_free(this_obj_conv);
43927 }
43928
43929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43930         LDKNodeFeatures this_obj_conv;
43931         this_obj_conv.inner = untag_ptr(this_obj);
43932         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43934         NodeFeatures_free(this_obj_conv);
43935 }
43936
43937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43938         LDKChannelFeatures this_obj_conv;
43939         this_obj_conv.inner = untag_ptr(this_obj);
43940         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43942         ChannelFeatures_free(this_obj_conv);
43943 }
43944
43945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43946         LDKInvoiceFeatures this_obj_conv;
43947         this_obj_conv.inner = untag_ptr(this_obj);
43948         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43950         InvoiceFeatures_free(this_obj_conv);
43951 }
43952
43953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43954         LDKOfferFeatures this_obj_conv;
43955         this_obj_conv.inner = untag_ptr(this_obj);
43956         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43958         OfferFeatures_free(this_obj_conv);
43959 }
43960
43961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43962         LDKInvoiceRequestFeatures this_obj_conv;
43963         this_obj_conv.inner = untag_ptr(this_obj);
43964         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43966         InvoiceRequestFeatures_free(this_obj_conv);
43967 }
43968
43969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43970         LDKChannelTypeFeatures this_obj_conv;
43971         this_obj_conv.inner = untag_ptr(this_obj);
43972         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43974         ChannelTypeFeatures_free(this_obj_conv);
43975 }
43976
43977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
43978         LDKInitFeatures ret_var = InitFeatures_empty();
43979         int64_t ret_ref = 0;
43980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43982         return ret_ref;
43983 }
43984
43985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
43986         LDKInitFeatures this_arg_conv;
43987         this_arg_conv.inner = untag_ptr(this_arg);
43988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43990         this_arg_conv.is_owned = false;
43991         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
43992         return ret_conv;
43993 }
43994
43995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
43996         LDKNodeFeatures ret_var = NodeFeatures_empty();
43997         int64_t ret_ref = 0;
43998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44000         return ret_ref;
44001 }
44002
44003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44004         LDKNodeFeatures this_arg_conv;
44005         this_arg_conv.inner = untag_ptr(this_arg);
44006         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44008         this_arg_conv.is_owned = false;
44009         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
44010         return ret_conv;
44011 }
44012
44013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
44014         LDKChannelFeatures ret_var = ChannelFeatures_empty();
44015         int64_t ret_ref = 0;
44016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44017         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44018         return ret_ref;
44019 }
44020
44021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44022         LDKChannelFeatures this_arg_conv;
44023         this_arg_conv.inner = untag_ptr(this_arg);
44024         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44026         this_arg_conv.is_owned = false;
44027         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
44028         return ret_conv;
44029 }
44030
44031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
44032         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
44033         int64_t ret_ref = 0;
44034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44035         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44036         return ret_ref;
44037 }
44038
44039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44040         LDKInvoiceFeatures this_arg_conv;
44041         this_arg_conv.inner = untag_ptr(this_arg);
44042         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44044         this_arg_conv.is_owned = false;
44045         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
44046         return ret_conv;
44047 }
44048
44049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1empty(JNIEnv *env, jclass clz) {
44050         LDKOfferFeatures ret_var = OfferFeatures_empty();
44051         int64_t ret_ref = 0;
44052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44054         return ret_ref;
44055 }
44056
44057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44058         LDKOfferFeatures this_arg_conv;
44059         this_arg_conv.inner = untag_ptr(this_arg);
44060         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44062         this_arg_conv.is_owned = false;
44063         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
44064         return ret_conv;
44065 }
44066
44067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1empty(JNIEnv *env, jclass clz) {
44068         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
44069         int64_t ret_ref = 0;
44070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44072         return ret_ref;
44073 }
44074
44075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44076         LDKInvoiceRequestFeatures this_arg_conv;
44077         this_arg_conv.inner = untag_ptr(this_arg);
44078         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44080         this_arg_conv.is_owned = false;
44081         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
44082         return ret_conv;
44083 }
44084
44085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
44086         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
44087         int64_t ret_ref = 0;
44088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44089         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44090         return ret_ref;
44091 }
44092
44093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44094         LDKChannelTypeFeatures this_arg_conv;
44095         this_arg_conv.inner = untag_ptr(this_arg);
44096         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44098         this_arg_conv.is_owned = false;
44099         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
44100         return ret_conv;
44101 }
44102
44103 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44104         LDKInitFeatures obj_conv;
44105         obj_conv.inner = untag_ptr(obj);
44106         obj_conv.is_owned = ptr_is_owned(obj);
44107         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44108         obj_conv.is_owned = false;
44109         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
44110         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44111         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44112         CVec_u8Z_free(ret_var);
44113         return ret_arr;
44114 }
44115
44116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44117         LDKu8slice ser_ref;
44118         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44119         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44120         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
44121         *ret_conv = InitFeatures_read(ser_ref);
44122         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44123         return tag_ptr(ret_conv, true);
44124 }
44125
44126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44127         LDKChannelFeatures obj_conv;
44128         obj_conv.inner = untag_ptr(obj);
44129         obj_conv.is_owned = ptr_is_owned(obj);
44130         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44131         obj_conv.is_owned = false;
44132         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
44133         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44134         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44135         CVec_u8Z_free(ret_var);
44136         return ret_arr;
44137 }
44138
44139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44140         LDKu8slice ser_ref;
44141         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44142         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44143         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
44144         *ret_conv = ChannelFeatures_read(ser_ref);
44145         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44146         return tag_ptr(ret_conv, true);
44147 }
44148
44149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44150         LDKNodeFeatures obj_conv;
44151         obj_conv.inner = untag_ptr(obj);
44152         obj_conv.is_owned = ptr_is_owned(obj);
44153         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44154         obj_conv.is_owned = false;
44155         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
44156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44158         CVec_u8Z_free(ret_var);
44159         return ret_arr;
44160 }
44161
44162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44163         LDKu8slice ser_ref;
44164         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44165         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44166         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
44167         *ret_conv = NodeFeatures_read(ser_ref);
44168         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44169         return tag_ptr(ret_conv, true);
44170 }
44171
44172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44173         LDKInvoiceFeatures obj_conv;
44174         obj_conv.inner = untag_ptr(obj);
44175         obj_conv.is_owned = ptr_is_owned(obj);
44176         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44177         obj_conv.is_owned = false;
44178         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
44179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44181         CVec_u8Z_free(ret_var);
44182         return ret_arr;
44183 }
44184
44185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44186         LDKu8slice ser_ref;
44187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44189         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
44190         *ret_conv = InvoiceFeatures_read(ser_ref);
44191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44192         return tag_ptr(ret_conv, true);
44193 }
44194
44195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44196         LDKChannelTypeFeatures obj_conv;
44197         obj_conv.inner = untag_ptr(obj);
44198         obj_conv.is_owned = ptr_is_owned(obj);
44199         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44200         obj_conv.is_owned = false;
44201         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
44202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44204         CVec_u8Z_free(ret_var);
44205         return ret_arr;
44206 }
44207
44208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44209         LDKu8slice ser_ref;
44210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44212         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
44213         *ret_conv = ChannelTypeFeatures_read(ser_ref);
44214         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44215         return tag_ptr(ret_conv, true);
44216 }
44217
44218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44219         LDKOfferFeatures obj_conv;
44220         obj_conv.inner = untag_ptr(obj);
44221         obj_conv.is_owned = ptr_is_owned(obj);
44222         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44223         obj_conv.is_owned = false;
44224         LDKCVec_u8Z ret_var = OfferFeatures_write(&obj_conv);
44225         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44226         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44227         CVec_u8Z_free(ret_var);
44228         return ret_arr;
44229 }
44230
44231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44232         LDKu8slice ser_ref;
44233         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44234         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44235         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
44236         *ret_conv = OfferFeatures_read(ser_ref);
44237         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44238         return tag_ptr(ret_conv, true);
44239 }
44240
44241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44242         LDKInvoiceRequestFeatures obj_conv;
44243         obj_conv.inner = untag_ptr(obj);
44244         obj_conv.is_owned = ptr_is_owned(obj);
44245         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44246         obj_conv.is_owned = false;
44247         LDKCVec_u8Z ret_var = InvoiceRequestFeatures_write(&obj_conv);
44248         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44249         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44250         CVec_u8Z_free(ret_var);
44251         return ret_arr;
44252 }
44253
44254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44255         LDKu8slice ser_ref;
44256         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44257         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44258         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
44259         *ret_conv = InvoiceRequestFeatures_read(ser_ref);
44260         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44261         return tag_ptr(ret_conv, true);
44262 }
44263
44264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44265         LDKInitFeatures this_arg_conv;
44266         this_arg_conv.inner = untag_ptr(this_arg);
44267         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44269         this_arg_conv.is_owned = false;
44270         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
44271 }
44272
44273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44274         LDKInitFeatures this_arg_conv;
44275         this_arg_conv.inner = untag_ptr(this_arg);
44276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44278         this_arg_conv.is_owned = false;
44279         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
44280 }
44281
44282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44283         LDKInitFeatures this_arg_conv;
44284         this_arg_conv.inner = untag_ptr(this_arg);
44285         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44287         this_arg_conv.is_owned = false;
44288         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
44289         return ret_conv;
44290 }
44291
44292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44293         LDKNodeFeatures this_arg_conv;
44294         this_arg_conv.inner = untag_ptr(this_arg);
44295         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44297         this_arg_conv.is_owned = false;
44298         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
44299 }
44300
44301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44302         LDKNodeFeatures this_arg_conv;
44303         this_arg_conv.inner = untag_ptr(this_arg);
44304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44306         this_arg_conv.is_owned = false;
44307         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
44308 }
44309
44310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44311         LDKNodeFeatures this_arg_conv;
44312         this_arg_conv.inner = untag_ptr(this_arg);
44313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44315         this_arg_conv.is_owned = false;
44316         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
44317         return ret_conv;
44318 }
44319
44320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44321         LDKInitFeatures this_arg_conv;
44322         this_arg_conv.inner = untag_ptr(this_arg);
44323         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44325         this_arg_conv.is_owned = false;
44326         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
44327         return ret_conv;
44328 }
44329
44330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44331         LDKNodeFeatures this_arg_conv;
44332         this_arg_conv.inner = untag_ptr(this_arg);
44333         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44335         this_arg_conv.is_owned = false;
44336         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
44337         return ret_conv;
44338 }
44339
44340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44341         LDKInitFeatures this_arg_conv;
44342         this_arg_conv.inner = untag_ptr(this_arg);
44343         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44345         this_arg_conv.is_owned = false;
44346         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
44347 }
44348
44349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44350         LDKInitFeatures this_arg_conv;
44351         this_arg_conv.inner = untag_ptr(this_arg);
44352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44354         this_arg_conv.is_owned = false;
44355         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
44356 }
44357
44358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
44359         LDKInitFeatures this_arg_conv;
44360         this_arg_conv.inner = untag_ptr(this_arg);
44361         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44363         this_arg_conv.is_owned = false;
44364         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
44365         return ret_conv;
44366 }
44367
44368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44369         LDKInitFeatures this_arg_conv;
44370         this_arg_conv.inner = untag_ptr(this_arg);
44371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44373         this_arg_conv.is_owned = false;
44374         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
44375 }
44376
44377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44378         LDKInitFeatures this_arg_conv;
44379         this_arg_conv.inner = untag_ptr(this_arg);
44380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44382         this_arg_conv.is_owned = false;
44383         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
44384 }
44385
44386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44387         LDKInitFeatures this_arg_conv;
44388         this_arg_conv.inner = untag_ptr(this_arg);
44389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44391         this_arg_conv.is_owned = false;
44392         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
44393         return ret_conv;
44394 }
44395
44396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44397         LDKNodeFeatures this_arg_conv;
44398         this_arg_conv.inner = untag_ptr(this_arg);
44399         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44401         this_arg_conv.is_owned = false;
44402         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
44403 }
44404
44405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44406         LDKNodeFeatures this_arg_conv;
44407         this_arg_conv.inner = untag_ptr(this_arg);
44408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44410         this_arg_conv.is_owned = false;
44411         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
44412 }
44413
44414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44415         LDKNodeFeatures this_arg_conv;
44416         this_arg_conv.inner = untag_ptr(this_arg);
44417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44419         this_arg_conv.is_owned = false;
44420         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
44421         return ret_conv;
44422 }
44423
44424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44425         LDKInitFeatures this_arg_conv;
44426         this_arg_conv.inner = untag_ptr(this_arg);
44427         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44429         this_arg_conv.is_owned = false;
44430         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
44431         return ret_conv;
44432 }
44433
44434 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44435         LDKNodeFeatures this_arg_conv;
44436         this_arg_conv.inner = untag_ptr(this_arg);
44437         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44439         this_arg_conv.is_owned = false;
44440         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
44441         return ret_conv;
44442 }
44443
44444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44445         LDKInitFeatures this_arg_conv;
44446         this_arg_conv.inner = untag_ptr(this_arg);
44447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44449         this_arg_conv.is_owned = false;
44450         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
44451 }
44452
44453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44454         LDKInitFeatures this_arg_conv;
44455         this_arg_conv.inner = untag_ptr(this_arg);
44456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44458         this_arg_conv.is_owned = false;
44459         InitFeatures_set_gossip_queries_required(&this_arg_conv);
44460 }
44461
44462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44463         LDKInitFeatures this_arg_conv;
44464         this_arg_conv.inner = untag_ptr(this_arg);
44465         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44467         this_arg_conv.is_owned = false;
44468         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
44469         return ret_conv;
44470 }
44471
44472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44473         LDKNodeFeatures this_arg_conv;
44474         this_arg_conv.inner = untag_ptr(this_arg);
44475         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44477         this_arg_conv.is_owned = false;
44478         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
44479 }
44480
44481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44482         LDKNodeFeatures this_arg_conv;
44483         this_arg_conv.inner = untag_ptr(this_arg);
44484         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44486         this_arg_conv.is_owned = false;
44487         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
44488 }
44489
44490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44491         LDKNodeFeatures this_arg_conv;
44492         this_arg_conv.inner = untag_ptr(this_arg);
44493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44495         this_arg_conv.is_owned = false;
44496         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
44497         return ret_conv;
44498 }
44499
44500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44501         LDKInitFeatures this_arg_conv;
44502         this_arg_conv.inner = untag_ptr(this_arg);
44503         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44505         this_arg_conv.is_owned = false;
44506         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
44507         return ret_conv;
44508 }
44509
44510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44511         LDKNodeFeatures this_arg_conv;
44512         this_arg_conv.inner = untag_ptr(this_arg);
44513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44515         this_arg_conv.is_owned = false;
44516         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
44517         return ret_conv;
44518 }
44519
44520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44521         LDKInitFeatures this_arg_conv;
44522         this_arg_conv.inner = untag_ptr(this_arg);
44523         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44525         this_arg_conv.is_owned = false;
44526         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
44527 }
44528
44529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44530         LDKInitFeatures this_arg_conv;
44531         this_arg_conv.inner = untag_ptr(this_arg);
44532         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44534         this_arg_conv.is_owned = false;
44535         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
44536 }
44537
44538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44539         LDKInitFeatures this_arg_conv;
44540         this_arg_conv.inner = untag_ptr(this_arg);
44541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44543         this_arg_conv.is_owned = false;
44544         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
44545         return ret_conv;
44546 }
44547
44548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44549         LDKNodeFeatures this_arg_conv;
44550         this_arg_conv.inner = untag_ptr(this_arg);
44551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44553         this_arg_conv.is_owned = false;
44554         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
44555 }
44556
44557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44558         LDKNodeFeatures this_arg_conv;
44559         this_arg_conv.inner = untag_ptr(this_arg);
44560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44562         this_arg_conv.is_owned = false;
44563         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
44564 }
44565
44566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44567         LDKNodeFeatures this_arg_conv;
44568         this_arg_conv.inner = untag_ptr(this_arg);
44569         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44571         this_arg_conv.is_owned = false;
44572         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
44573         return ret_conv;
44574 }
44575
44576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44577         LDKInvoiceFeatures this_arg_conv;
44578         this_arg_conv.inner = untag_ptr(this_arg);
44579         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44581         this_arg_conv.is_owned = false;
44582         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
44583 }
44584
44585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44586         LDKInvoiceFeatures this_arg_conv;
44587         this_arg_conv.inner = untag_ptr(this_arg);
44588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44590         this_arg_conv.is_owned = false;
44591         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
44592 }
44593
44594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44595         LDKInvoiceFeatures this_arg_conv;
44596         this_arg_conv.inner = untag_ptr(this_arg);
44597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44599         this_arg_conv.is_owned = false;
44600         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
44601         return ret_conv;
44602 }
44603
44604 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44605         LDKInitFeatures this_arg_conv;
44606         this_arg_conv.inner = untag_ptr(this_arg);
44607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44609         this_arg_conv.is_owned = false;
44610         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
44611         return ret_conv;
44612 }
44613
44614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44615         LDKNodeFeatures this_arg_conv;
44616         this_arg_conv.inner = untag_ptr(this_arg);
44617         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44619         this_arg_conv.is_owned = false;
44620         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
44621         return ret_conv;
44622 }
44623
44624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44625         LDKInvoiceFeatures this_arg_conv;
44626         this_arg_conv.inner = untag_ptr(this_arg);
44627         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44629         this_arg_conv.is_owned = false;
44630         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
44631         return ret_conv;
44632 }
44633
44634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44635         LDKInitFeatures this_arg_conv;
44636         this_arg_conv.inner = untag_ptr(this_arg);
44637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44639         this_arg_conv.is_owned = false;
44640         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
44641 }
44642
44643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44644         LDKInitFeatures this_arg_conv;
44645         this_arg_conv.inner = untag_ptr(this_arg);
44646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44648         this_arg_conv.is_owned = false;
44649         InitFeatures_set_static_remote_key_required(&this_arg_conv);
44650 }
44651
44652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44653         LDKInitFeatures this_arg_conv;
44654         this_arg_conv.inner = untag_ptr(this_arg);
44655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44657         this_arg_conv.is_owned = false;
44658         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
44659         return ret_conv;
44660 }
44661
44662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44663         LDKNodeFeatures this_arg_conv;
44664         this_arg_conv.inner = untag_ptr(this_arg);
44665         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44667         this_arg_conv.is_owned = false;
44668         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
44669 }
44670
44671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44672         LDKNodeFeatures this_arg_conv;
44673         this_arg_conv.inner = untag_ptr(this_arg);
44674         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44676         this_arg_conv.is_owned = false;
44677         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
44678 }
44679
44680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44681         LDKNodeFeatures this_arg_conv;
44682         this_arg_conv.inner = untag_ptr(this_arg);
44683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44685         this_arg_conv.is_owned = false;
44686         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
44687         return ret_conv;
44688 }
44689
44690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44691         LDKChannelTypeFeatures this_arg_conv;
44692         this_arg_conv.inner = untag_ptr(this_arg);
44693         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44695         this_arg_conv.is_owned = false;
44696         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
44697 }
44698
44699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44700         LDKChannelTypeFeatures this_arg_conv;
44701         this_arg_conv.inner = untag_ptr(this_arg);
44702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44704         this_arg_conv.is_owned = false;
44705         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
44706 }
44707
44708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44709         LDKChannelTypeFeatures this_arg_conv;
44710         this_arg_conv.inner = untag_ptr(this_arg);
44711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44713         this_arg_conv.is_owned = false;
44714         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
44715         return ret_conv;
44716 }
44717
44718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44719         LDKInitFeatures this_arg_conv;
44720         this_arg_conv.inner = untag_ptr(this_arg);
44721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44723         this_arg_conv.is_owned = false;
44724         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
44725         return ret_conv;
44726 }
44727
44728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44729         LDKNodeFeatures this_arg_conv;
44730         this_arg_conv.inner = untag_ptr(this_arg);
44731         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44733         this_arg_conv.is_owned = false;
44734         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
44735         return ret_conv;
44736 }
44737
44738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44739         LDKChannelTypeFeatures this_arg_conv;
44740         this_arg_conv.inner = untag_ptr(this_arg);
44741         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44743         this_arg_conv.is_owned = false;
44744         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
44745         return ret_conv;
44746 }
44747
44748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44749         LDKInitFeatures this_arg_conv;
44750         this_arg_conv.inner = untag_ptr(this_arg);
44751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44753         this_arg_conv.is_owned = false;
44754         InitFeatures_set_payment_secret_optional(&this_arg_conv);
44755 }
44756
44757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44758         LDKInitFeatures this_arg_conv;
44759         this_arg_conv.inner = untag_ptr(this_arg);
44760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44762         this_arg_conv.is_owned = false;
44763         InitFeatures_set_payment_secret_required(&this_arg_conv);
44764 }
44765
44766 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44767         LDKInitFeatures this_arg_conv;
44768         this_arg_conv.inner = untag_ptr(this_arg);
44769         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44771         this_arg_conv.is_owned = false;
44772         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
44773         return ret_conv;
44774 }
44775
44776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44777         LDKNodeFeatures this_arg_conv;
44778         this_arg_conv.inner = untag_ptr(this_arg);
44779         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44781         this_arg_conv.is_owned = false;
44782         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
44783 }
44784
44785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44786         LDKNodeFeatures this_arg_conv;
44787         this_arg_conv.inner = untag_ptr(this_arg);
44788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44790         this_arg_conv.is_owned = false;
44791         NodeFeatures_set_payment_secret_required(&this_arg_conv);
44792 }
44793
44794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44795         LDKNodeFeatures this_arg_conv;
44796         this_arg_conv.inner = untag_ptr(this_arg);
44797         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44799         this_arg_conv.is_owned = false;
44800         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
44801         return ret_conv;
44802 }
44803
44804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44805         LDKInvoiceFeatures this_arg_conv;
44806         this_arg_conv.inner = untag_ptr(this_arg);
44807         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44809         this_arg_conv.is_owned = false;
44810         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
44811 }
44812
44813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44814         LDKInvoiceFeatures this_arg_conv;
44815         this_arg_conv.inner = untag_ptr(this_arg);
44816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44818         this_arg_conv.is_owned = false;
44819         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
44820 }
44821
44822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44823         LDKInvoiceFeatures this_arg_conv;
44824         this_arg_conv.inner = untag_ptr(this_arg);
44825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44827         this_arg_conv.is_owned = false;
44828         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
44829         return ret_conv;
44830 }
44831
44832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44833         LDKInitFeatures this_arg_conv;
44834         this_arg_conv.inner = untag_ptr(this_arg);
44835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44837         this_arg_conv.is_owned = false;
44838         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
44839         return ret_conv;
44840 }
44841
44842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44843         LDKNodeFeatures this_arg_conv;
44844         this_arg_conv.inner = untag_ptr(this_arg);
44845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44847         this_arg_conv.is_owned = false;
44848         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
44849         return ret_conv;
44850 }
44851
44852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44853         LDKInvoiceFeatures this_arg_conv;
44854         this_arg_conv.inner = untag_ptr(this_arg);
44855         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44857         this_arg_conv.is_owned = false;
44858         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
44859         return ret_conv;
44860 }
44861
44862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44863         LDKInitFeatures this_arg_conv;
44864         this_arg_conv.inner = untag_ptr(this_arg);
44865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44867         this_arg_conv.is_owned = false;
44868         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
44869 }
44870
44871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44872         LDKInitFeatures this_arg_conv;
44873         this_arg_conv.inner = untag_ptr(this_arg);
44874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44876         this_arg_conv.is_owned = false;
44877         InitFeatures_set_basic_mpp_required(&this_arg_conv);
44878 }
44879
44880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44881         LDKInitFeatures this_arg_conv;
44882         this_arg_conv.inner = untag_ptr(this_arg);
44883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44885         this_arg_conv.is_owned = false;
44886         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
44887         return ret_conv;
44888 }
44889
44890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44891         LDKNodeFeatures this_arg_conv;
44892         this_arg_conv.inner = untag_ptr(this_arg);
44893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44895         this_arg_conv.is_owned = false;
44896         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
44897 }
44898
44899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44900         LDKNodeFeatures this_arg_conv;
44901         this_arg_conv.inner = untag_ptr(this_arg);
44902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44904         this_arg_conv.is_owned = false;
44905         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
44906 }
44907
44908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44909         LDKNodeFeatures this_arg_conv;
44910         this_arg_conv.inner = untag_ptr(this_arg);
44911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44913         this_arg_conv.is_owned = false;
44914         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
44915         return ret_conv;
44916 }
44917
44918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44919         LDKInvoiceFeatures this_arg_conv;
44920         this_arg_conv.inner = untag_ptr(this_arg);
44921         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44923         this_arg_conv.is_owned = false;
44924         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
44925 }
44926
44927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44928         LDKInvoiceFeatures this_arg_conv;
44929         this_arg_conv.inner = untag_ptr(this_arg);
44930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44932         this_arg_conv.is_owned = false;
44933         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
44934 }
44935
44936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44937         LDKInvoiceFeatures this_arg_conv;
44938         this_arg_conv.inner = untag_ptr(this_arg);
44939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44941         this_arg_conv.is_owned = false;
44942         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
44943         return ret_conv;
44944 }
44945
44946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44947         LDKInitFeatures this_arg_conv;
44948         this_arg_conv.inner = untag_ptr(this_arg);
44949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44951         this_arg_conv.is_owned = false;
44952         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
44953         return ret_conv;
44954 }
44955
44956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44957         LDKNodeFeatures this_arg_conv;
44958         this_arg_conv.inner = untag_ptr(this_arg);
44959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44961         this_arg_conv.is_owned = false;
44962         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
44963         return ret_conv;
44964 }
44965
44966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44967         LDKInvoiceFeatures this_arg_conv;
44968         this_arg_conv.inner = untag_ptr(this_arg);
44969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44971         this_arg_conv.is_owned = false;
44972         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
44973         return ret_conv;
44974 }
44975
44976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44977         LDKInitFeatures this_arg_conv;
44978         this_arg_conv.inner = untag_ptr(this_arg);
44979         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44981         this_arg_conv.is_owned = false;
44982         InitFeatures_set_wumbo_optional(&this_arg_conv);
44983 }
44984
44985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44986         LDKInitFeatures this_arg_conv;
44987         this_arg_conv.inner = untag_ptr(this_arg);
44988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44990         this_arg_conv.is_owned = false;
44991         InitFeatures_set_wumbo_required(&this_arg_conv);
44992 }
44993
44994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
44995         LDKInitFeatures this_arg_conv;
44996         this_arg_conv.inner = untag_ptr(this_arg);
44997         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44999         this_arg_conv.is_owned = false;
45000         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
45001         return ret_conv;
45002 }
45003
45004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45005         LDKNodeFeatures this_arg_conv;
45006         this_arg_conv.inner = untag_ptr(this_arg);
45007         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45009         this_arg_conv.is_owned = false;
45010         NodeFeatures_set_wumbo_optional(&this_arg_conv);
45011 }
45012
45013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45014         LDKNodeFeatures this_arg_conv;
45015         this_arg_conv.inner = untag_ptr(this_arg);
45016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45018         this_arg_conv.is_owned = false;
45019         NodeFeatures_set_wumbo_required(&this_arg_conv);
45020 }
45021
45022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45023         LDKNodeFeatures this_arg_conv;
45024         this_arg_conv.inner = untag_ptr(this_arg);
45025         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45027         this_arg_conv.is_owned = false;
45028         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
45029         return ret_conv;
45030 }
45031
45032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45033         LDKInitFeatures this_arg_conv;
45034         this_arg_conv.inner = untag_ptr(this_arg);
45035         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45037         this_arg_conv.is_owned = false;
45038         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
45039         return ret_conv;
45040 }
45041
45042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45043         LDKNodeFeatures this_arg_conv;
45044         this_arg_conv.inner = untag_ptr(this_arg);
45045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45047         this_arg_conv.is_owned = false;
45048         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
45049         return ret_conv;
45050 }
45051
45052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45053         LDKInitFeatures this_arg_conv;
45054         this_arg_conv.inner = untag_ptr(this_arg);
45055         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45057         this_arg_conv.is_owned = false;
45058         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
45059 }
45060
45061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45062         LDKInitFeatures this_arg_conv;
45063         this_arg_conv.inner = untag_ptr(this_arg);
45064         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45066         this_arg_conv.is_owned = false;
45067         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
45068 }
45069
45070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45071         LDKInitFeatures this_arg_conv;
45072         this_arg_conv.inner = untag_ptr(this_arg);
45073         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45075         this_arg_conv.is_owned = false;
45076         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
45077         return ret_conv;
45078 }
45079
45080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45081         LDKNodeFeatures this_arg_conv;
45082         this_arg_conv.inner = untag_ptr(this_arg);
45083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45085         this_arg_conv.is_owned = false;
45086         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
45087 }
45088
45089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45090         LDKNodeFeatures this_arg_conv;
45091         this_arg_conv.inner = untag_ptr(this_arg);
45092         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45094         this_arg_conv.is_owned = false;
45095         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
45096 }
45097
45098 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45099         LDKNodeFeatures this_arg_conv;
45100         this_arg_conv.inner = untag_ptr(this_arg);
45101         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45103         this_arg_conv.is_owned = false;
45104         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
45105         return ret_conv;
45106 }
45107
45108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45109         LDKInitFeatures this_arg_conv;
45110         this_arg_conv.inner = untag_ptr(this_arg);
45111         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45113         this_arg_conv.is_owned = false;
45114         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
45115         return ret_conv;
45116 }
45117
45118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45119         LDKNodeFeatures this_arg_conv;
45120         this_arg_conv.inner = untag_ptr(this_arg);
45121         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45123         this_arg_conv.is_owned = false;
45124         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
45125         return ret_conv;
45126 }
45127
45128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45129         LDKInitFeatures this_arg_conv;
45130         this_arg_conv.inner = untag_ptr(this_arg);
45131         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45133         this_arg_conv.is_owned = false;
45134         InitFeatures_set_onion_messages_optional(&this_arg_conv);
45135 }
45136
45137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45138         LDKInitFeatures this_arg_conv;
45139         this_arg_conv.inner = untag_ptr(this_arg);
45140         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45142         this_arg_conv.is_owned = false;
45143         InitFeatures_set_onion_messages_required(&this_arg_conv);
45144 }
45145
45146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45147         LDKInitFeatures this_arg_conv;
45148         this_arg_conv.inner = untag_ptr(this_arg);
45149         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45151         this_arg_conv.is_owned = false;
45152         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
45153         return ret_conv;
45154 }
45155
45156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45157         LDKNodeFeatures this_arg_conv;
45158         this_arg_conv.inner = untag_ptr(this_arg);
45159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45161         this_arg_conv.is_owned = false;
45162         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
45163 }
45164
45165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45166         LDKNodeFeatures this_arg_conv;
45167         this_arg_conv.inner = untag_ptr(this_arg);
45168         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45170         this_arg_conv.is_owned = false;
45171         NodeFeatures_set_onion_messages_required(&this_arg_conv);
45172 }
45173
45174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45175         LDKNodeFeatures this_arg_conv;
45176         this_arg_conv.inner = untag_ptr(this_arg);
45177         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45179         this_arg_conv.is_owned = false;
45180         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
45181         return ret_conv;
45182 }
45183
45184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45185         LDKInitFeatures this_arg_conv;
45186         this_arg_conv.inner = untag_ptr(this_arg);
45187         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45189         this_arg_conv.is_owned = false;
45190         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
45191         return ret_conv;
45192 }
45193
45194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45195         LDKNodeFeatures this_arg_conv;
45196         this_arg_conv.inner = untag_ptr(this_arg);
45197         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45199         this_arg_conv.is_owned = false;
45200         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
45201         return ret_conv;
45202 }
45203
45204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45205         LDKInitFeatures this_arg_conv;
45206         this_arg_conv.inner = untag_ptr(this_arg);
45207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45209         this_arg_conv.is_owned = false;
45210         InitFeatures_set_channel_type_optional(&this_arg_conv);
45211 }
45212
45213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45214         LDKInitFeatures this_arg_conv;
45215         this_arg_conv.inner = untag_ptr(this_arg);
45216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45218         this_arg_conv.is_owned = false;
45219         InitFeatures_set_channel_type_required(&this_arg_conv);
45220 }
45221
45222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45223         LDKInitFeatures this_arg_conv;
45224         this_arg_conv.inner = untag_ptr(this_arg);
45225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45227         this_arg_conv.is_owned = false;
45228         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
45229         return ret_conv;
45230 }
45231
45232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45233         LDKNodeFeatures this_arg_conv;
45234         this_arg_conv.inner = untag_ptr(this_arg);
45235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45237         this_arg_conv.is_owned = false;
45238         NodeFeatures_set_channel_type_optional(&this_arg_conv);
45239 }
45240
45241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45242         LDKNodeFeatures this_arg_conv;
45243         this_arg_conv.inner = untag_ptr(this_arg);
45244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45246         this_arg_conv.is_owned = false;
45247         NodeFeatures_set_channel_type_required(&this_arg_conv);
45248 }
45249
45250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45251         LDKNodeFeatures this_arg_conv;
45252         this_arg_conv.inner = untag_ptr(this_arg);
45253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45255         this_arg_conv.is_owned = false;
45256         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
45257         return ret_conv;
45258 }
45259
45260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45261         LDKInitFeatures this_arg_conv;
45262         this_arg_conv.inner = untag_ptr(this_arg);
45263         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45265         this_arg_conv.is_owned = false;
45266         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
45267         return ret_conv;
45268 }
45269
45270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45271         LDKNodeFeatures this_arg_conv;
45272         this_arg_conv.inner = untag_ptr(this_arg);
45273         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45275         this_arg_conv.is_owned = false;
45276         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
45277         return ret_conv;
45278 }
45279
45280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45281         LDKInitFeatures this_arg_conv;
45282         this_arg_conv.inner = untag_ptr(this_arg);
45283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45285         this_arg_conv.is_owned = false;
45286         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
45287 }
45288
45289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45290         LDKInitFeatures this_arg_conv;
45291         this_arg_conv.inner = untag_ptr(this_arg);
45292         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45294         this_arg_conv.is_owned = false;
45295         InitFeatures_set_scid_privacy_required(&this_arg_conv);
45296 }
45297
45298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45299         LDKInitFeatures this_arg_conv;
45300         this_arg_conv.inner = untag_ptr(this_arg);
45301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45303         this_arg_conv.is_owned = false;
45304         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
45305         return ret_conv;
45306 }
45307
45308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45309         LDKNodeFeatures this_arg_conv;
45310         this_arg_conv.inner = untag_ptr(this_arg);
45311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45313         this_arg_conv.is_owned = false;
45314         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
45315 }
45316
45317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45318         LDKNodeFeatures this_arg_conv;
45319         this_arg_conv.inner = untag_ptr(this_arg);
45320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45322         this_arg_conv.is_owned = false;
45323         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
45324 }
45325
45326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45327         LDKNodeFeatures this_arg_conv;
45328         this_arg_conv.inner = untag_ptr(this_arg);
45329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45331         this_arg_conv.is_owned = false;
45332         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
45333         return ret_conv;
45334 }
45335
45336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45337         LDKChannelTypeFeatures this_arg_conv;
45338         this_arg_conv.inner = untag_ptr(this_arg);
45339         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45341         this_arg_conv.is_owned = false;
45342         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
45343 }
45344
45345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45346         LDKChannelTypeFeatures this_arg_conv;
45347         this_arg_conv.inner = untag_ptr(this_arg);
45348         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45350         this_arg_conv.is_owned = false;
45351         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
45352 }
45353
45354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45355         LDKChannelTypeFeatures this_arg_conv;
45356         this_arg_conv.inner = untag_ptr(this_arg);
45357         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45359         this_arg_conv.is_owned = false;
45360         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
45361         return ret_conv;
45362 }
45363
45364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45365         LDKInitFeatures this_arg_conv;
45366         this_arg_conv.inner = untag_ptr(this_arg);
45367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45369         this_arg_conv.is_owned = false;
45370         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
45371         return ret_conv;
45372 }
45373
45374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45375         LDKNodeFeatures this_arg_conv;
45376         this_arg_conv.inner = untag_ptr(this_arg);
45377         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45379         this_arg_conv.is_owned = false;
45380         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
45381         return ret_conv;
45382 }
45383
45384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45385         LDKChannelTypeFeatures this_arg_conv;
45386         this_arg_conv.inner = untag_ptr(this_arg);
45387         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45389         this_arg_conv.is_owned = false;
45390         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
45391         return ret_conv;
45392 }
45393
45394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45395         LDKInitFeatures this_arg_conv;
45396         this_arg_conv.inner = untag_ptr(this_arg);
45397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45399         this_arg_conv.is_owned = false;
45400         InitFeatures_set_zero_conf_optional(&this_arg_conv);
45401 }
45402
45403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45404         LDKInitFeatures this_arg_conv;
45405         this_arg_conv.inner = untag_ptr(this_arg);
45406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45408         this_arg_conv.is_owned = false;
45409         InitFeatures_set_zero_conf_required(&this_arg_conv);
45410 }
45411
45412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45413         LDKInitFeatures this_arg_conv;
45414         this_arg_conv.inner = untag_ptr(this_arg);
45415         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45417         this_arg_conv.is_owned = false;
45418         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
45419         return ret_conv;
45420 }
45421
45422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45423         LDKNodeFeatures this_arg_conv;
45424         this_arg_conv.inner = untag_ptr(this_arg);
45425         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45427         this_arg_conv.is_owned = false;
45428         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
45429 }
45430
45431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45432         LDKNodeFeatures this_arg_conv;
45433         this_arg_conv.inner = untag_ptr(this_arg);
45434         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45436         this_arg_conv.is_owned = false;
45437         NodeFeatures_set_zero_conf_required(&this_arg_conv);
45438 }
45439
45440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45441         LDKNodeFeatures this_arg_conv;
45442         this_arg_conv.inner = untag_ptr(this_arg);
45443         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45445         this_arg_conv.is_owned = false;
45446         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
45447         return ret_conv;
45448 }
45449
45450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45451         LDKChannelTypeFeatures this_arg_conv;
45452         this_arg_conv.inner = untag_ptr(this_arg);
45453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45455         this_arg_conv.is_owned = false;
45456         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
45457 }
45458
45459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45460         LDKChannelTypeFeatures this_arg_conv;
45461         this_arg_conv.inner = untag_ptr(this_arg);
45462         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45464         this_arg_conv.is_owned = false;
45465         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
45466 }
45467
45468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45469         LDKChannelTypeFeatures this_arg_conv;
45470         this_arg_conv.inner = untag_ptr(this_arg);
45471         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45473         this_arg_conv.is_owned = false;
45474         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
45475         return ret_conv;
45476 }
45477
45478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45479         LDKInitFeatures this_arg_conv;
45480         this_arg_conv.inner = untag_ptr(this_arg);
45481         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45483         this_arg_conv.is_owned = false;
45484         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
45485         return ret_conv;
45486 }
45487
45488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45489         LDKNodeFeatures this_arg_conv;
45490         this_arg_conv.inner = untag_ptr(this_arg);
45491         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45493         this_arg_conv.is_owned = false;
45494         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
45495         return ret_conv;
45496 }
45497
45498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45499         LDKChannelTypeFeatures this_arg_conv;
45500         this_arg_conv.inner = untag_ptr(this_arg);
45501         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45503         this_arg_conv.is_owned = false;
45504         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
45505         return ret_conv;
45506 }
45507
45508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45509         LDKNodeFeatures this_arg_conv;
45510         this_arg_conv.inner = untag_ptr(this_arg);
45511         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45513         this_arg_conv.is_owned = false;
45514         NodeFeatures_set_keysend_optional(&this_arg_conv);
45515 }
45516
45517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45518         LDKNodeFeatures this_arg_conv;
45519         this_arg_conv.inner = untag_ptr(this_arg);
45520         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45522         this_arg_conv.is_owned = false;
45523         NodeFeatures_set_keysend_required(&this_arg_conv);
45524 }
45525
45526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
45527         LDKNodeFeatures this_arg_conv;
45528         this_arg_conv.inner = untag_ptr(this_arg);
45529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45531         this_arg_conv.is_owned = false;
45532         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
45533         return ret_conv;
45534 }
45535
45536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
45537         LDKNodeFeatures this_arg_conv;
45538         this_arg_conv.inner = untag_ptr(this_arg);
45539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45541         this_arg_conv.is_owned = false;
45542         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
45543         return ret_conv;
45544 }
45545
45546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45547         LDKShutdownScript this_obj_conv;
45548         this_obj_conv.inner = untag_ptr(this_obj);
45549         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45551         ShutdownScript_free(this_obj_conv);
45552 }
45553
45554 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
45555         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
45556         int64_t ret_ref = 0;
45557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45558         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45559         return ret_ref;
45560 }
45561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45562         LDKShutdownScript arg_conv;
45563         arg_conv.inner = untag_ptr(arg);
45564         arg_conv.is_owned = ptr_is_owned(arg);
45565         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45566         arg_conv.is_owned = false;
45567         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
45568         return ret_conv;
45569 }
45570
45571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45572         LDKShutdownScript orig_conv;
45573         orig_conv.inner = untag_ptr(orig);
45574         orig_conv.is_owned = ptr_is_owned(orig);
45575         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45576         orig_conv.is_owned = false;
45577         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
45578         int64_t ret_ref = 0;
45579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45580         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45581         return ret_ref;
45582 }
45583
45584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45585         LDKShutdownScript a_conv;
45586         a_conv.inner = untag_ptr(a);
45587         a_conv.is_owned = ptr_is_owned(a);
45588         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45589         a_conv.is_owned = false;
45590         LDKShutdownScript b_conv;
45591         b_conv.inner = untag_ptr(b);
45592         b_conv.is_owned = ptr_is_owned(b);
45593         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45594         b_conv.is_owned = false;
45595         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
45596         return ret_conv;
45597 }
45598
45599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45600         LDKInvalidShutdownScript this_obj_conv;
45601         this_obj_conv.inner = untag_ptr(this_obj);
45602         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45604         InvalidShutdownScript_free(this_obj_conv);
45605 }
45606
45607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
45608         LDKInvalidShutdownScript this_ptr_conv;
45609         this_ptr_conv.inner = untag_ptr(this_ptr);
45610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45612         this_ptr_conv.is_owned = false;
45613         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
45614         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45615         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45616         return ret_arr;
45617 }
45618
45619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45620         LDKInvalidShutdownScript this_ptr_conv;
45621         this_ptr_conv.inner = untag_ptr(this_ptr);
45622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45624         this_ptr_conv.is_owned = false;
45625         LDKCVec_u8Z val_ref;
45626         val_ref.datalen = (*env)->GetArrayLength(env, val);
45627         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
45628         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
45629         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
45630 }
45631
45632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
45633         LDKCVec_u8Z script_arg_ref;
45634         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
45635         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
45636         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
45637         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
45638         int64_t ret_ref = 0;
45639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45640         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45641         return ret_ref;
45642 }
45643
45644 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
45645         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
45646         int64_t ret_ref = 0;
45647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45649         return ret_ref;
45650 }
45651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45652         LDKInvalidShutdownScript arg_conv;
45653         arg_conv.inner = untag_ptr(arg);
45654         arg_conv.is_owned = ptr_is_owned(arg);
45655         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45656         arg_conv.is_owned = false;
45657         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
45658         return ret_conv;
45659 }
45660
45661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45662         LDKInvalidShutdownScript orig_conv;
45663         orig_conv.inner = untag_ptr(orig);
45664         orig_conv.is_owned = ptr_is_owned(orig);
45665         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45666         orig_conv.is_owned = false;
45667         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
45668         int64_t ret_ref = 0;
45669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45671         return ret_ref;
45672 }
45673
45674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
45675         LDKShutdownScript obj_conv;
45676         obj_conv.inner = untag_ptr(obj);
45677         obj_conv.is_owned = ptr_is_owned(obj);
45678         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45679         obj_conv.is_owned = false;
45680         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
45681         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45682         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45683         CVec_u8Z_free(ret_var);
45684         return ret_arr;
45685 }
45686
45687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45688         LDKu8slice ser_ref;
45689         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45690         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45691         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
45692         *ret_conv = ShutdownScript_read(ser_ref);
45693         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45694         return tag_ptr(ret_conv, true);
45695 }
45696
45697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
45698         unsigned char pubkey_hash_arr[20];
45699         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
45700         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
45701         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
45702         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
45703         int64_t ret_ref = 0;
45704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45706         return ret_ref;
45707 }
45708
45709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
45710         unsigned char script_hash_arr[32];
45711         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
45712         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
45713         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
45714         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
45715         int64_t ret_ref = 0;
45716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45718         return ret_ref;
45719 }
45720
45721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
45722         
45723         LDKu8slice program_ref;
45724         program_ref.datalen = (*env)->GetArrayLength(env, program);
45725         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
45726         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
45727         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
45728         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
45729         return tag_ptr(ret_conv, true);
45730 }
45731
45732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45733         LDKShutdownScript this_arg_conv;
45734         this_arg_conv.inner = untag_ptr(this_arg);
45735         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45737         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
45738         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
45739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45741         CVec_u8Z_free(ret_var);
45742         return ret_arr;
45743 }
45744
45745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
45746         LDKShutdownScript this_arg_conv;
45747         this_arg_conv.inner = untag_ptr(this_arg);
45748         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45750         this_arg_conv.is_owned = false;
45751         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45752         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
45753         return ret_arr;
45754 }
45755
45756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
45757         LDKShutdownScript this_arg_conv;
45758         this_arg_conv.inner = untag_ptr(this_arg);
45759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45761         this_arg_conv.is_owned = false;
45762         LDKInitFeatures features_conv;
45763         features_conv.inner = untag_ptr(features);
45764         features_conv.is_owned = ptr_is_owned(features);
45765         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
45766         features_conv.is_owned = false;
45767         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
45768         return ret_conv;
45769 }
45770
45771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45772         if (!ptr_is_owned(this_ptr)) return;
45773         void* this_ptr_ptr = untag_ptr(this_ptr);
45774         CHECK_ACCESS(this_ptr_ptr);
45775         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
45776         FREE(untag_ptr(this_ptr));
45777         CustomMessageReader_free(this_ptr_conv);
45778 }
45779
45780 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
45781         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
45782         *ret_ret = Type_clone(arg);
45783         return tag_ptr(ret_ret, true);
45784 }
45785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45786         void* arg_ptr = untag_ptr(arg);
45787         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
45788         LDKType* arg_conv = (LDKType*)arg_ptr;
45789         int64_t ret_conv = Type_clone_ptr(arg_conv);
45790         return ret_conv;
45791 }
45792
45793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45794         void* orig_ptr = untag_ptr(orig);
45795         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
45796         LDKType* orig_conv = (LDKType*)orig_ptr;
45797         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
45798         *ret_ret = Type_clone(orig_conv);
45799         return tag_ptr(ret_ret, true);
45800 }
45801
45802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45803         if (!ptr_is_owned(this_ptr)) return;
45804         void* this_ptr_ptr = untag_ptr(this_ptr);
45805         CHECK_ACCESS(this_ptr_ptr);
45806         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
45807         FREE(untag_ptr(this_ptr));
45808         Type_free(this_ptr_conv);
45809 }
45810
45811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45812         LDKNodeId this_obj_conv;
45813         this_obj_conv.inner = untag_ptr(this_obj);
45814         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45816         NodeId_free(this_obj_conv);
45817 }
45818
45819 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
45820         LDKNodeId ret_var = NodeId_clone(arg);
45821         int64_t ret_ref = 0;
45822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45824         return ret_ref;
45825 }
45826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45827         LDKNodeId arg_conv;
45828         arg_conv.inner = untag_ptr(arg);
45829         arg_conv.is_owned = ptr_is_owned(arg);
45830         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45831         arg_conv.is_owned = false;
45832         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
45833         return ret_conv;
45834 }
45835
45836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45837         LDKNodeId orig_conv;
45838         orig_conv.inner = untag_ptr(orig);
45839         orig_conv.is_owned = ptr_is_owned(orig);
45840         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45841         orig_conv.is_owned = false;
45842         LDKNodeId ret_var = NodeId_clone(&orig_conv);
45843         int64_t ret_ref = 0;
45844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45845         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45846         return ret_ref;
45847 }
45848
45849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
45850         LDKPublicKey pubkey_ref;
45851         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
45852         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
45853         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
45854         int64_t ret_ref = 0;
45855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45857         return ret_ref;
45858 }
45859
45860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
45861         LDKNodeId this_arg_conv;
45862         this_arg_conv.inner = untag_ptr(this_arg);
45863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45865         this_arg_conv.is_owned = false;
45866         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
45867         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45868         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45869         return ret_arr;
45870 }
45871
45872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
45873         LDKNodeId o_conv;
45874         o_conv.inner = untag_ptr(o);
45875         o_conv.is_owned = ptr_is_owned(o);
45876         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45877         o_conv.is_owned = false;
45878         int64_t ret_conv = NodeId_hash(&o_conv);
45879         return ret_conv;
45880 }
45881
45882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
45883         LDKNodeId obj_conv;
45884         obj_conv.inner = untag_ptr(obj);
45885         obj_conv.is_owned = ptr_is_owned(obj);
45886         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45887         obj_conv.is_owned = false;
45888         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
45889         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45890         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45891         CVec_u8Z_free(ret_var);
45892         return ret_arr;
45893 }
45894
45895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45896         LDKu8slice ser_ref;
45897         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45898         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45899         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
45900         *ret_conv = NodeId_read(ser_ref);
45901         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45902         return tag_ptr(ret_conv, true);
45903 }
45904
45905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45906         LDKNetworkGraph this_obj_conv;
45907         this_obj_conv.inner = untag_ptr(this_obj);
45908         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45910         NetworkGraph_free(this_obj_conv);
45911 }
45912
45913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45914         LDKReadOnlyNetworkGraph this_obj_conv;
45915         this_obj_conv.inner = untag_ptr(this_obj);
45916         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45918         ReadOnlyNetworkGraph_free(this_obj_conv);
45919 }
45920
45921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45922         if (!ptr_is_owned(this_ptr)) return;
45923         void* this_ptr_ptr = untag_ptr(this_ptr);
45924         CHECK_ACCESS(this_ptr_ptr);
45925         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
45926         FREE(untag_ptr(this_ptr));
45927         NetworkUpdate_free(this_ptr_conv);
45928 }
45929
45930 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
45931         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45932         *ret_copy = NetworkUpdate_clone(arg);
45933         int64_t ret_ref = tag_ptr(ret_copy, true);
45934         return ret_ref;
45935 }
45936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45937         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
45938         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
45939         return ret_conv;
45940 }
45941
45942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45943         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
45944         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45945         *ret_copy = NetworkUpdate_clone(orig_conv);
45946         int64_t ret_ref = tag_ptr(ret_copy, true);
45947         return ret_ref;
45948 }
45949
45950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
45951         LDKChannelUpdate msg_conv;
45952         msg_conv.inner = untag_ptr(msg);
45953         msg_conv.is_owned = ptr_is_owned(msg);
45954         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45955         msg_conv = ChannelUpdate_clone(&msg_conv);
45956         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45957         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
45958         int64_t ret_ref = tag_ptr(ret_copy, true);
45959         return ret_ref;
45960 }
45961
45962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
45963         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45964         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
45965         int64_t ret_ref = tag_ptr(ret_copy, true);
45966         return ret_ref;
45967 }
45968
45969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
45970         LDKPublicKey node_id_ref;
45971         CHECK((*env)->GetArrayLength(env, node_id) == 33);
45972         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
45973         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45974         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
45975         int64_t ret_ref = tag_ptr(ret_copy, true);
45976         return ret_ref;
45977 }
45978
45979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45980         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
45981         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
45982         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
45983         return ret_conv;
45984 }
45985
45986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
45987         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
45988         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
45989         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45990         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45991         CVec_u8Z_free(ret_var);
45992         return ret_arr;
45993 }
45994
45995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45996         LDKu8slice ser_ref;
45997         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45998         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45999         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
46000         *ret_conv = NetworkUpdate_read(ser_ref);
46001         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46002         return tag_ptr(ret_conv, true);
46003 }
46004
46005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46006         LDKP2PGossipSync this_obj_conv;
46007         this_obj_conv.inner = untag_ptr(this_obj);
46008         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46010         P2PGossipSync_free(this_obj_conv);
46011 }
46012
46013 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) {
46014         LDKNetworkGraph network_graph_conv;
46015         network_graph_conv.inner = untag_ptr(network_graph);
46016         network_graph_conv.is_owned = ptr_is_owned(network_graph);
46017         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46018         network_graph_conv.is_owned = false;
46019         void* chain_access_ptr = untag_ptr(chain_access);
46020         CHECK_ACCESS(chain_access_ptr);
46021         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46022         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46023         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46024                 // Manually implement clone for Java trait instances
46025                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46026                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46027                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46028                 }
46029         }
46030         void* logger_ptr = untag_ptr(logger);
46031         CHECK_ACCESS(logger_ptr);
46032         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46033         if (logger_conv.free == LDKLogger_JCalls_free) {
46034                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46035                 LDKLogger_JCalls_cloned(&logger_conv);
46036         }
46037         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
46038         int64_t ret_ref = 0;
46039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46041         return ret_ref;
46042 }
46043
46044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
46045         LDKP2PGossipSync this_arg_conv;
46046         this_arg_conv.inner = untag_ptr(this_arg);
46047         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46049         this_arg_conv.is_owned = false;
46050         void* chain_access_ptr = untag_ptr(chain_access);
46051         CHECK_ACCESS(chain_access_ptr);
46052         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46053         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46054         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46055                 // Manually implement clone for Java trait instances
46056                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46057                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46058                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46059                 }
46060         }
46061         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
46062 }
46063
46064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1handle_1network_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_update) {
46065         LDKNetworkGraph this_arg_conv;
46066         this_arg_conv.inner = untag_ptr(this_arg);
46067         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46069         this_arg_conv.is_owned = false;
46070         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
46071         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
46072 }
46073
46074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
46075         LDKP2PGossipSync this_arg_conv;
46076         this_arg_conv.inner = untag_ptr(this_arg);
46077         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46079         this_arg_conv.is_owned = false;
46080         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
46081         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
46082         return tag_ptr(ret_ret, true);
46083 }
46084
46085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
46086         LDKP2PGossipSync this_arg_conv;
46087         this_arg_conv.inner = untag_ptr(this_arg);
46088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46090         this_arg_conv.is_owned = false;
46091         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
46092         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
46093         return tag_ptr(ret_ret, true);
46094 }
46095
46096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46097         LDKChannelUpdateInfo this_obj_conv;
46098         this_obj_conv.inner = untag_ptr(this_obj);
46099         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46101         ChannelUpdateInfo_free(this_obj_conv);
46102 }
46103
46104 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
46105         LDKChannelUpdateInfo this_ptr_conv;
46106         this_ptr_conv.inner = untag_ptr(this_ptr);
46107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46109         this_ptr_conv.is_owned = false;
46110         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
46111         return ret_conv;
46112 }
46113
46114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46115         LDKChannelUpdateInfo this_ptr_conv;
46116         this_ptr_conv.inner = untag_ptr(this_ptr);
46117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46119         this_ptr_conv.is_owned = false;
46120         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
46121 }
46122
46123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
46124         LDKChannelUpdateInfo this_ptr_conv;
46125         this_ptr_conv.inner = untag_ptr(this_ptr);
46126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46128         this_ptr_conv.is_owned = false;
46129         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
46130         return ret_conv;
46131 }
46132
46133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
46134         LDKChannelUpdateInfo this_ptr_conv;
46135         this_ptr_conv.inner = untag_ptr(this_ptr);
46136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46138         this_ptr_conv.is_owned = false;
46139         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
46140 }
46141
46142 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46143         LDKChannelUpdateInfo this_ptr_conv;
46144         this_ptr_conv.inner = untag_ptr(this_ptr);
46145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46147         this_ptr_conv.is_owned = false;
46148         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
46149         return ret_conv;
46150 }
46151
46152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
46153         LDKChannelUpdateInfo this_ptr_conv;
46154         this_ptr_conv.inner = untag_ptr(this_ptr);
46155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46157         this_ptr_conv.is_owned = false;
46158         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
46159 }
46160
46161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46162         LDKChannelUpdateInfo this_ptr_conv;
46163         this_ptr_conv.inner = untag_ptr(this_ptr);
46164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46166         this_ptr_conv.is_owned = false;
46167         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
46168         return ret_conv;
46169 }
46170
46171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46172         LDKChannelUpdateInfo this_ptr_conv;
46173         this_ptr_conv.inner = untag_ptr(this_ptr);
46174         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46176         this_ptr_conv.is_owned = false;
46177         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
46178 }
46179
46180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46181         LDKChannelUpdateInfo this_ptr_conv;
46182         this_ptr_conv.inner = untag_ptr(this_ptr);
46183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46185         this_ptr_conv.is_owned = false;
46186         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
46187         return ret_conv;
46188 }
46189
46190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46191         LDKChannelUpdateInfo this_ptr_conv;
46192         this_ptr_conv.inner = untag_ptr(this_ptr);
46193         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46195         this_ptr_conv.is_owned = false;
46196         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
46197 }
46198
46199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
46200         LDKChannelUpdateInfo this_ptr_conv;
46201         this_ptr_conv.inner = untag_ptr(this_ptr);
46202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46204         this_ptr_conv.is_owned = false;
46205         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
46206         int64_t ret_ref = 0;
46207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46209         return ret_ref;
46210 }
46211
46212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46213         LDKChannelUpdateInfo this_ptr_conv;
46214         this_ptr_conv.inner = untag_ptr(this_ptr);
46215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46217         this_ptr_conv.is_owned = false;
46218         LDKRoutingFees val_conv;
46219         val_conv.inner = untag_ptr(val);
46220         val_conv.is_owned = ptr_is_owned(val);
46221         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46222         val_conv = RoutingFees_clone(&val_conv);
46223         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
46224 }
46225
46226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
46227         LDKChannelUpdateInfo this_ptr_conv;
46228         this_ptr_conv.inner = untag_ptr(this_ptr);
46229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46231         this_ptr_conv.is_owned = false;
46232         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
46233         int64_t ret_ref = 0;
46234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46236         return ret_ref;
46237 }
46238
46239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46240         LDKChannelUpdateInfo this_ptr_conv;
46241         this_ptr_conv.inner = untag_ptr(this_ptr);
46242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46244         this_ptr_conv.is_owned = false;
46245         LDKChannelUpdate val_conv;
46246         val_conv.inner = untag_ptr(val);
46247         val_conv.is_owned = ptr_is_owned(val);
46248         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46249         val_conv = ChannelUpdate_clone(&val_conv);
46250         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
46251 }
46252
46253 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) {
46254         LDKRoutingFees fees_arg_conv;
46255         fees_arg_conv.inner = untag_ptr(fees_arg);
46256         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
46257         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
46258         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
46259         LDKChannelUpdate last_update_message_arg_conv;
46260         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
46261         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
46262         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
46263         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
46264         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);
46265         int64_t ret_ref = 0;
46266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46268         return ret_ref;
46269 }
46270
46271 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
46272         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
46273         int64_t ret_ref = 0;
46274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46275         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46276         return ret_ref;
46277 }
46278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46279         LDKChannelUpdateInfo arg_conv;
46280         arg_conv.inner = untag_ptr(arg);
46281         arg_conv.is_owned = ptr_is_owned(arg);
46282         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46283         arg_conv.is_owned = false;
46284         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
46285         return ret_conv;
46286 }
46287
46288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46289         LDKChannelUpdateInfo orig_conv;
46290         orig_conv.inner = untag_ptr(orig);
46291         orig_conv.is_owned = ptr_is_owned(orig);
46292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46293         orig_conv.is_owned = false;
46294         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
46295         int64_t ret_ref = 0;
46296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46297         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46298         return ret_ref;
46299 }
46300
46301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46302         LDKChannelUpdateInfo a_conv;
46303         a_conv.inner = untag_ptr(a);
46304         a_conv.is_owned = ptr_is_owned(a);
46305         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46306         a_conv.is_owned = false;
46307         LDKChannelUpdateInfo b_conv;
46308         b_conv.inner = untag_ptr(b);
46309         b_conv.is_owned = ptr_is_owned(b);
46310         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46311         b_conv.is_owned = false;
46312         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
46313         return ret_conv;
46314 }
46315
46316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
46317         LDKChannelUpdateInfo obj_conv;
46318         obj_conv.inner = untag_ptr(obj);
46319         obj_conv.is_owned = ptr_is_owned(obj);
46320         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46321         obj_conv.is_owned = false;
46322         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
46323         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46324         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46325         CVec_u8Z_free(ret_var);
46326         return ret_arr;
46327 }
46328
46329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46330         LDKu8slice ser_ref;
46331         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46332         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46333         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
46334         *ret_conv = ChannelUpdateInfo_read(ser_ref);
46335         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46336         return tag_ptr(ret_conv, true);
46337 }
46338
46339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46340         LDKChannelInfo this_obj_conv;
46341         this_obj_conv.inner = untag_ptr(this_obj);
46342         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46344         ChannelInfo_free(this_obj_conv);
46345 }
46346
46347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46348         LDKChannelInfo this_ptr_conv;
46349         this_ptr_conv.inner = untag_ptr(this_ptr);
46350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46352         this_ptr_conv.is_owned = false;
46353         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
46354         int64_t ret_ref = 0;
46355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46356         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46357         return ret_ref;
46358 }
46359
46360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46361         LDKChannelInfo this_ptr_conv;
46362         this_ptr_conv.inner = untag_ptr(this_ptr);
46363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46365         this_ptr_conv.is_owned = false;
46366         LDKChannelFeatures val_conv;
46367         val_conv.inner = untag_ptr(val);
46368         val_conv.is_owned = ptr_is_owned(val);
46369         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46370         val_conv = ChannelFeatures_clone(&val_conv);
46371         ChannelInfo_set_features(&this_ptr_conv, val_conv);
46372 }
46373
46374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
46375         LDKChannelInfo this_ptr_conv;
46376         this_ptr_conv.inner = untag_ptr(this_ptr);
46377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46379         this_ptr_conv.is_owned = false;
46380         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
46381         int64_t ret_ref = 0;
46382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46383         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46384         return ret_ref;
46385 }
46386
46387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46388         LDKChannelInfo this_ptr_conv;
46389         this_ptr_conv.inner = untag_ptr(this_ptr);
46390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46392         this_ptr_conv.is_owned = false;
46393         LDKNodeId val_conv;
46394         val_conv.inner = untag_ptr(val);
46395         val_conv.is_owned = ptr_is_owned(val);
46396         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46397         val_conv = NodeId_clone(&val_conv);
46398         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
46399 }
46400
46401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
46402         LDKChannelInfo this_ptr_conv;
46403         this_ptr_conv.inner = untag_ptr(this_ptr);
46404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46406         this_ptr_conv.is_owned = false;
46407         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
46408         int64_t ret_ref = 0;
46409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46410         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46411         return ret_ref;
46412 }
46413
46414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46415         LDKChannelInfo this_ptr_conv;
46416         this_ptr_conv.inner = untag_ptr(this_ptr);
46417         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46419         this_ptr_conv.is_owned = false;
46420         LDKChannelUpdateInfo val_conv;
46421         val_conv.inner = untag_ptr(val);
46422         val_conv.is_owned = ptr_is_owned(val);
46423         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46424         val_conv = ChannelUpdateInfo_clone(&val_conv);
46425         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
46426 }
46427
46428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
46429         LDKChannelInfo this_ptr_conv;
46430         this_ptr_conv.inner = untag_ptr(this_ptr);
46431         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46433         this_ptr_conv.is_owned = false;
46434         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
46435         int64_t ret_ref = 0;
46436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46438         return ret_ref;
46439 }
46440
46441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46442         LDKChannelInfo this_ptr_conv;
46443         this_ptr_conv.inner = untag_ptr(this_ptr);
46444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46446         this_ptr_conv.is_owned = false;
46447         LDKNodeId val_conv;
46448         val_conv.inner = untag_ptr(val);
46449         val_conv.is_owned = ptr_is_owned(val);
46450         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46451         val_conv = NodeId_clone(&val_conv);
46452         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
46453 }
46454
46455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
46456         LDKChannelInfo this_ptr_conv;
46457         this_ptr_conv.inner = untag_ptr(this_ptr);
46458         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46460         this_ptr_conv.is_owned = false;
46461         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
46462         int64_t ret_ref = 0;
46463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46465         return ret_ref;
46466 }
46467
46468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46469         LDKChannelInfo this_ptr_conv;
46470         this_ptr_conv.inner = untag_ptr(this_ptr);
46471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46473         this_ptr_conv.is_owned = false;
46474         LDKChannelUpdateInfo val_conv;
46475         val_conv.inner = untag_ptr(val);
46476         val_conv.is_owned = ptr_is_owned(val);
46477         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46478         val_conv = ChannelUpdateInfo_clone(&val_conv);
46479         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
46480 }
46481
46482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
46483         LDKChannelInfo this_ptr_conv;
46484         this_ptr_conv.inner = untag_ptr(this_ptr);
46485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46487         this_ptr_conv.is_owned = false;
46488         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46489         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
46490         int64_t ret_ref = tag_ptr(ret_copy, true);
46491         return ret_ref;
46492 }
46493
46494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46495         LDKChannelInfo this_ptr_conv;
46496         this_ptr_conv.inner = untag_ptr(this_ptr);
46497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46499         this_ptr_conv.is_owned = false;
46500         void* val_ptr = untag_ptr(val);
46501         CHECK_ACCESS(val_ptr);
46502         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46503         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
46504         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
46505 }
46506
46507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
46508         LDKChannelInfo this_ptr_conv;
46509         this_ptr_conv.inner = untag_ptr(this_ptr);
46510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46512         this_ptr_conv.is_owned = false;
46513         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
46514         int64_t ret_ref = 0;
46515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46517         return ret_ref;
46518 }
46519
46520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46521         LDKChannelInfo this_ptr_conv;
46522         this_ptr_conv.inner = untag_ptr(this_ptr);
46523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46525         this_ptr_conv.is_owned = false;
46526         LDKChannelAnnouncement val_conv;
46527         val_conv.inner = untag_ptr(val);
46528         val_conv.is_owned = ptr_is_owned(val);
46529         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46530         val_conv = ChannelAnnouncement_clone(&val_conv);
46531         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
46532 }
46533
46534 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
46535         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
46536         int64_t ret_ref = 0;
46537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46539         return ret_ref;
46540 }
46541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46542         LDKChannelInfo arg_conv;
46543         arg_conv.inner = untag_ptr(arg);
46544         arg_conv.is_owned = ptr_is_owned(arg);
46545         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46546         arg_conv.is_owned = false;
46547         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
46548         return ret_conv;
46549 }
46550
46551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46552         LDKChannelInfo orig_conv;
46553         orig_conv.inner = untag_ptr(orig);
46554         orig_conv.is_owned = ptr_is_owned(orig);
46555         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46556         orig_conv.is_owned = false;
46557         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
46558         int64_t ret_ref = 0;
46559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46561         return ret_ref;
46562 }
46563
46564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46565         LDKChannelInfo a_conv;
46566         a_conv.inner = untag_ptr(a);
46567         a_conv.is_owned = ptr_is_owned(a);
46568         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46569         a_conv.is_owned = false;
46570         LDKChannelInfo b_conv;
46571         b_conv.inner = untag_ptr(b);
46572         b_conv.is_owned = ptr_is_owned(b);
46573         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46574         b_conv.is_owned = false;
46575         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
46576         return ret_conv;
46577 }
46578
46579 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) {
46580         LDKChannelInfo this_arg_conv;
46581         this_arg_conv.inner = untag_ptr(this_arg);
46582         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46584         this_arg_conv.is_owned = false;
46585         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
46586         int64_t ret_ref = 0;
46587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46588         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46589         return ret_ref;
46590 }
46591
46592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
46593         LDKChannelInfo obj_conv;
46594         obj_conv.inner = untag_ptr(obj);
46595         obj_conv.is_owned = ptr_is_owned(obj);
46596         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46597         obj_conv.is_owned = false;
46598         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
46599         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46600         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46601         CVec_u8Z_free(ret_var);
46602         return ret_arr;
46603 }
46604
46605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46606         LDKu8slice ser_ref;
46607         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46608         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46609         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
46610         *ret_conv = ChannelInfo_read(ser_ref);
46611         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46612         return tag_ptr(ret_conv, true);
46613 }
46614
46615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46616         LDKDirectedChannelInfo this_obj_conv;
46617         this_obj_conv.inner = untag_ptr(this_obj);
46618         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46620         DirectedChannelInfo_free(this_obj_conv);
46621 }
46622
46623 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
46624         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
46625         int64_t ret_ref = 0;
46626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46628         return ret_ref;
46629 }
46630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46631         LDKDirectedChannelInfo arg_conv;
46632         arg_conv.inner = untag_ptr(arg);
46633         arg_conv.is_owned = ptr_is_owned(arg);
46634         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46635         arg_conv.is_owned = false;
46636         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
46637         return ret_conv;
46638 }
46639
46640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46641         LDKDirectedChannelInfo orig_conv;
46642         orig_conv.inner = untag_ptr(orig);
46643         orig_conv.is_owned = ptr_is_owned(orig);
46644         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46645         orig_conv.is_owned = false;
46646         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
46647         int64_t ret_ref = 0;
46648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46649         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46650         return ret_ref;
46651 }
46652
46653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
46654         LDKDirectedChannelInfo this_arg_conv;
46655         this_arg_conv.inner = untag_ptr(this_arg);
46656         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46658         this_arg_conv.is_owned = false;
46659         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
46660         int64_t ret_ref = 0;
46661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46662         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46663         return ret_ref;
46664 }
46665
46666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
46667         LDKDirectedChannelInfo this_arg_conv;
46668         this_arg_conv.inner = untag_ptr(this_arg);
46669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46671         this_arg_conv.is_owned = false;
46672         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
46673         return ret_conv;
46674 }
46675
46676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
46677         LDKDirectedChannelInfo this_arg_conv;
46678         this_arg_conv.inner = untag_ptr(this_arg);
46679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46681         this_arg_conv.is_owned = false;
46682         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46683         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
46684         int64_t ret_ref = tag_ptr(ret_copy, true);
46685         return ret_ref;
46686 }
46687
46688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46689         if (!ptr_is_owned(this_ptr)) return;
46690         void* this_ptr_ptr = untag_ptr(this_ptr);
46691         CHECK_ACCESS(this_ptr_ptr);
46692         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
46693         FREE(untag_ptr(this_ptr));
46694         EffectiveCapacity_free(this_ptr_conv);
46695 }
46696
46697 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
46698         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46699         *ret_copy = EffectiveCapacity_clone(arg);
46700         int64_t ret_ref = tag_ptr(ret_copy, true);
46701         return ret_ref;
46702 }
46703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46704         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
46705         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
46706         return ret_conv;
46707 }
46708
46709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46710         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
46711         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46712         *ret_copy = EffectiveCapacity_clone(orig_conv);
46713         int64_t ret_ref = tag_ptr(ret_copy, true);
46714         return ret_ref;
46715 }
46716
46717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
46718         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46719         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
46720         int64_t ret_ref = tag_ptr(ret_copy, true);
46721         return ret_ref;
46722 }
46723
46724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
46725         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46726         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
46727         int64_t ret_ref = tag_ptr(ret_copy, true);
46728         return ret_ref;
46729 }
46730
46731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
46732         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46733         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
46734         int64_t ret_ref = tag_ptr(ret_copy, true);
46735         return ret_ref;
46736 }
46737
46738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
46739         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46740         *ret_copy = EffectiveCapacity_infinite();
46741         int64_t ret_ref = tag_ptr(ret_copy, true);
46742         return ret_ref;
46743 }
46744
46745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
46746         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46747         *ret_copy = EffectiveCapacity_unknown();
46748         int64_t ret_ref = tag_ptr(ret_copy, true);
46749         return ret_ref;
46750 }
46751
46752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
46753         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
46754         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
46755         return ret_conv;
46756 }
46757
46758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46759         LDKRoutingFees this_obj_conv;
46760         this_obj_conv.inner = untag_ptr(this_obj);
46761         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46763         RoutingFees_free(this_obj_conv);
46764 }
46765
46766 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46767         LDKRoutingFees this_ptr_conv;
46768         this_ptr_conv.inner = untag_ptr(this_ptr);
46769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46771         this_ptr_conv.is_owned = false;
46772         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
46773         return ret_conv;
46774 }
46775
46776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46777         LDKRoutingFees this_ptr_conv;
46778         this_ptr_conv.inner = untag_ptr(this_ptr);
46779         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46781         this_ptr_conv.is_owned = false;
46782         RoutingFees_set_base_msat(&this_ptr_conv, val);
46783 }
46784
46785 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
46786         LDKRoutingFees this_ptr_conv;
46787         this_ptr_conv.inner = untag_ptr(this_ptr);
46788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46790         this_ptr_conv.is_owned = false;
46791         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
46792         return ret_conv;
46793 }
46794
46795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46796         LDKRoutingFees this_ptr_conv;
46797         this_ptr_conv.inner = untag_ptr(this_ptr);
46798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46800         this_ptr_conv.is_owned = false;
46801         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
46802 }
46803
46804 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) {
46805         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
46806         int64_t ret_ref = 0;
46807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46809         return ret_ref;
46810 }
46811
46812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46813         LDKRoutingFees a_conv;
46814         a_conv.inner = untag_ptr(a);
46815         a_conv.is_owned = ptr_is_owned(a);
46816         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46817         a_conv.is_owned = false;
46818         LDKRoutingFees b_conv;
46819         b_conv.inner = untag_ptr(b);
46820         b_conv.is_owned = ptr_is_owned(b);
46821         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46822         b_conv.is_owned = false;
46823         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
46824         return ret_conv;
46825 }
46826
46827 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
46828         LDKRoutingFees ret_var = RoutingFees_clone(arg);
46829         int64_t ret_ref = 0;
46830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46831         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46832         return ret_ref;
46833 }
46834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46835         LDKRoutingFees arg_conv;
46836         arg_conv.inner = untag_ptr(arg);
46837         arg_conv.is_owned = ptr_is_owned(arg);
46838         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46839         arg_conv.is_owned = false;
46840         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
46841         return ret_conv;
46842 }
46843
46844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46845         LDKRoutingFees orig_conv;
46846         orig_conv.inner = untag_ptr(orig);
46847         orig_conv.is_owned = ptr_is_owned(orig);
46848         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46849         orig_conv.is_owned = false;
46850         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
46851         int64_t ret_ref = 0;
46852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46853         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46854         return ret_ref;
46855 }
46856
46857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
46858         LDKRoutingFees o_conv;
46859         o_conv.inner = untag_ptr(o);
46860         o_conv.is_owned = ptr_is_owned(o);
46861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46862         o_conv.is_owned = false;
46863         int64_t ret_conv = RoutingFees_hash(&o_conv);
46864         return ret_conv;
46865 }
46866
46867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
46868         LDKRoutingFees obj_conv;
46869         obj_conv.inner = untag_ptr(obj);
46870         obj_conv.is_owned = ptr_is_owned(obj);
46871         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46872         obj_conv.is_owned = false;
46873         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
46874         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46875         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46876         CVec_u8Z_free(ret_var);
46877         return ret_arr;
46878 }
46879
46880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46881         LDKu8slice ser_ref;
46882         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46883         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46884         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
46885         *ret_conv = RoutingFees_read(ser_ref);
46886         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46887         return tag_ptr(ret_conv, true);
46888 }
46889
46890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46891         LDKNodeAnnouncementInfo this_obj_conv;
46892         this_obj_conv.inner = untag_ptr(this_obj);
46893         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46895         NodeAnnouncementInfo_free(this_obj_conv);
46896 }
46897
46898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46899         LDKNodeAnnouncementInfo this_ptr_conv;
46900         this_ptr_conv.inner = untag_ptr(this_ptr);
46901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46903         this_ptr_conv.is_owned = false;
46904         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
46905         int64_t ret_ref = 0;
46906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46908         return ret_ref;
46909 }
46910
46911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46912         LDKNodeAnnouncementInfo this_ptr_conv;
46913         this_ptr_conv.inner = untag_ptr(this_ptr);
46914         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46916         this_ptr_conv.is_owned = false;
46917         LDKNodeFeatures val_conv;
46918         val_conv.inner = untag_ptr(val);
46919         val_conv.is_owned = ptr_is_owned(val);
46920         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46921         val_conv = NodeFeatures_clone(&val_conv);
46922         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
46923 }
46924
46925 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
46926         LDKNodeAnnouncementInfo this_ptr_conv;
46927         this_ptr_conv.inner = untag_ptr(this_ptr);
46928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46930         this_ptr_conv.is_owned = false;
46931         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
46932         return ret_conv;
46933 }
46934
46935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46936         LDKNodeAnnouncementInfo this_ptr_conv;
46937         this_ptr_conv.inner = untag_ptr(this_ptr);
46938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46940         this_ptr_conv.is_owned = false;
46941         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
46942 }
46943
46944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
46945         LDKNodeAnnouncementInfo this_ptr_conv;
46946         this_ptr_conv.inner = untag_ptr(this_ptr);
46947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46949         this_ptr_conv.is_owned = false;
46950         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
46951         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
46952         return ret_arr;
46953 }
46954
46955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46956         LDKNodeAnnouncementInfo this_ptr_conv;
46957         this_ptr_conv.inner = untag_ptr(this_ptr);
46958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46960         this_ptr_conv.is_owned = false;
46961         LDKThreeBytes val_ref;
46962         CHECK((*env)->GetArrayLength(env, val) == 3);
46963         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
46964         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
46965 }
46966
46967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
46968         LDKNodeAnnouncementInfo this_ptr_conv;
46969         this_ptr_conv.inner = untag_ptr(this_ptr);
46970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46972         this_ptr_conv.is_owned = false;
46973         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
46974         int64_t ret_ref = 0;
46975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46977         return ret_ref;
46978 }
46979
46980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46981         LDKNodeAnnouncementInfo this_ptr_conv;
46982         this_ptr_conv.inner = untag_ptr(this_ptr);
46983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46985         this_ptr_conv.is_owned = false;
46986         LDKNodeAlias val_conv;
46987         val_conv.inner = untag_ptr(val);
46988         val_conv.is_owned = ptr_is_owned(val);
46989         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46990         val_conv = NodeAlias_clone(&val_conv);
46991         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
46992 }
46993
46994 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
46995         LDKNodeAnnouncementInfo this_ptr_conv;
46996         this_ptr_conv.inner = untag_ptr(this_ptr);
46997         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46999         this_ptr_conv.is_owned = false;
47000         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
47001         int64_tArray ret_arr = NULL;
47002         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47003         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47004         for (size_t m = 0; m < ret_var.datalen; m++) {
47005                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
47006                 *ret_conv_12_copy = ret_var.data[m];
47007                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
47008                 ret_arr_ptr[m] = ret_conv_12_ref;
47009         }
47010         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47011         FREE(ret_var.data);
47012         return ret_arr;
47013 }
47014
47015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47016         LDKNodeAnnouncementInfo this_ptr_conv;
47017         this_ptr_conv.inner = untag_ptr(this_ptr);
47018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47020         this_ptr_conv.is_owned = false;
47021         LDKCVec_NetAddressZ val_constr;
47022         val_constr.datalen = (*env)->GetArrayLength(env, val);
47023         if (val_constr.datalen > 0)
47024                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
47025         else
47026                 val_constr.data = NULL;
47027         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47028         for (size_t m = 0; m < val_constr.datalen; m++) {
47029                 int64_t val_conv_12 = val_vals[m];
47030                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
47031                 CHECK_ACCESS(val_conv_12_ptr);
47032                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
47033                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
47034                 val_constr.data[m] = val_conv_12_conv;
47035         }
47036         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47037         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
47038 }
47039
47040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
47041         LDKNodeAnnouncementInfo this_ptr_conv;
47042         this_ptr_conv.inner = untag_ptr(this_ptr);
47043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47045         this_ptr_conv.is_owned = false;
47046         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
47047         int64_t ret_ref = 0;
47048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47050         return ret_ref;
47051 }
47052
47053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47054         LDKNodeAnnouncementInfo this_ptr_conv;
47055         this_ptr_conv.inner = untag_ptr(this_ptr);
47056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47058         this_ptr_conv.is_owned = false;
47059         LDKNodeAnnouncement val_conv;
47060         val_conv.inner = untag_ptr(val);
47061         val_conv.is_owned = ptr_is_owned(val);
47062         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47063         val_conv = NodeAnnouncement_clone(&val_conv);
47064         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
47065 }
47066
47067 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) {
47068         LDKNodeFeatures features_arg_conv;
47069         features_arg_conv.inner = untag_ptr(features_arg);
47070         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47071         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47072         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
47073         LDKThreeBytes rgb_arg_ref;
47074         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
47075         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
47076         LDKNodeAlias alias_arg_conv;
47077         alias_arg_conv.inner = untag_ptr(alias_arg);
47078         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
47079         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
47080         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
47081         LDKCVec_NetAddressZ addresses_arg_constr;
47082         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
47083         if (addresses_arg_constr.datalen > 0)
47084                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
47085         else
47086                 addresses_arg_constr.data = NULL;
47087         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
47088         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
47089                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
47090                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
47091                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
47092                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
47093                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
47094         }
47095         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
47096         LDKNodeAnnouncement announcement_message_arg_conv;
47097         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
47098         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
47099         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
47100         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
47101         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
47102         int64_t ret_ref = 0;
47103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47104         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47105         return ret_ref;
47106 }
47107
47108 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
47109         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
47110         int64_t ret_ref = 0;
47111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47113         return ret_ref;
47114 }
47115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47116         LDKNodeAnnouncementInfo arg_conv;
47117         arg_conv.inner = untag_ptr(arg);
47118         arg_conv.is_owned = ptr_is_owned(arg);
47119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47120         arg_conv.is_owned = false;
47121         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
47122         return ret_conv;
47123 }
47124
47125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47126         LDKNodeAnnouncementInfo orig_conv;
47127         orig_conv.inner = untag_ptr(orig);
47128         orig_conv.is_owned = ptr_is_owned(orig);
47129         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47130         orig_conv.is_owned = false;
47131         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
47132         int64_t ret_ref = 0;
47133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47135         return ret_ref;
47136 }
47137
47138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47139         LDKNodeAnnouncementInfo a_conv;
47140         a_conv.inner = untag_ptr(a);
47141         a_conv.is_owned = ptr_is_owned(a);
47142         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47143         a_conv.is_owned = false;
47144         LDKNodeAnnouncementInfo b_conv;
47145         b_conv.inner = untag_ptr(b);
47146         b_conv.is_owned = ptr_is_owned(b);
47147         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47148         b_conv.is_owned = false;
47149         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
47150         return ret_conv;
47151 }
47152
47153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47154         LDKNodeAnnouncementInfo obj_conv;
47155         obj_conv.inner = untag_ptr(obj);
47156         obj_conv.is_owned = ptr_is_owned(obj);
47157         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47158         obj_conv.is_owned = false;
47159         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
47160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47162         CVec_u8Z_free(ret_var);
47163         return ret_arr;
47164 }
47165
47166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47167         LDKu8slice ser_ref;
47168         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47169         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47170         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
47171         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
47172         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47173         return tag_ptr(ret_conv, true);
47174 }
47175
47176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47177         LDKNodeAlias this_obj_conv;
47178         this_obj_conv.inner = untag_ptr(this_obj);
47179         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47181         NodeAlias_free(this_obj_conv);
47182 }
47183
47184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47185         LDKNodeAlias this_ptr_conv;
47186         this_ptr_conv.inner = untag_ptr(this_ptr);
47187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47189         this_ptr_conv.is_owned = false;
47190         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47191         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
47192         return ret_arr;
47193 }
47194
47195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47196         LDKNodeAlias this_ptr_conv;
47197         this_ptr_conv.inner = untag_ptr(this_ptr);
47198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47200         this_ptr_conv.is_owned = false;
47201         LDKThirtyTwoBytes val_ref;
47202         CHECK((*env)->GetArrayLength(env, val) == 32);
47203         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
47204         NodeAlias_set_a(&this_ptr_conv, val_ref);
47205 }
47206
47207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
47208         LDKThirtyTwoBytes a_arg_ref;
47209         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
47210         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
47211         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
47212         int64_t ret_ref = 0;
47213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47215         return ret_ref;
47216 }
47217
47218 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
47219         LDKNodeAlias ret_var = NodeAlias_clone(arg);
47220         int64_t ret_ref = 0;
47221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47223         return ret_ref;
47224 }
47225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47226         LDKNodeAlias arg_conv;
47227         arg_conv.inner = untag_ptr(arg);
47228         arg_conv.is_owned = ptr_is_owned(arg);
47229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47230         arg_conv.is_owned = false;
47231         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
47232         return ret_conv;
47233 }
47234
47235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47236         LDKNodeAlias orig_conv;
47237         orig_conv.inner = untag_ptr(orig);
47238         orig_conv.is_owned = ptr_is_owned(orig);
47239         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47240         orig_conv.is_owned = false;
47241         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
47242         int64_t ret_ref = 0;
47243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47245         return ret_ref;
47246 }
47247
47248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47249         LDKNodeAlias a_conv;
47250         a_conv.inner = untag_ptr(a);
47251         a_conv.is_owned = ptr_is_owned(a);
47252         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47253         a_conv.is_owned = false;
47254         LDKNodeAlias b_conv;
47255         b_conv.inner = untag_ptr(b);
47256         b_conv.is_owned = ptr_is_owned(b);
47257         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47258         b_conv.is_owned = false;
47259         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
47260         return ret_conv;
47261 }
47262
47263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
47264         LDKNodeAlias obj_conv;
47265         obj_conv.inner = untag_ptr(obj);
47266         obj_conv.is_owned = ptr_is_owned(obj);
47267         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47268         obj_conv.is_owned = false;
47269         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
47270         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47271         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47272         CVec_u8Z_free(ret_var);
47273         return ret_arr;
47274 }
47275
47276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47277         LDKu8slice ser_ref;
47278         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47279         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47280         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
47281         *ret_conv = NodeAlias_read(ser_ref);
47282         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47283         return tag_ptr(ret_conv, true);
47284 }
47285
47286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47287         LDKNodeInfo this_obj_conv;
47288         this_obj_conv.inner = untag_ptr(this_obj);
47289         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47291         NodeInfo_free(this_obj_conv);
47292 }
47293
47294 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
47295         LDKNodeInfo this_ptr_conv;
47296         this_ptr_conv.inner = untag_ptr(this_ptr);
47297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47299         this_ptr_conv.is_owned = false;
47300         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
47301         int64_tArray ret_arr = NULL;
47302         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47303         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47304         for (size_t g = 0; g < ret_var.datalen; g++) {
47305                 int64_t ret_conv_6_conv = ret_var.data[g];
47306                 ret_arr_ptr[g] = ret_conv_6_conv;
47307         }
47308         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47309         FREE(ret_var.data);
47310         return ret_arr;
47311 }
47312
47313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47314         LDKNodeInfo this_ptr_conv;
47315         this_ptr_conv.inner = untag_ptr(this_ptr);
47316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47318         this_ptr_conv.is_owned = false;
47319         LDKCVec_u64Z val_constr;
47320         val_constr.datalen = (*env)->GetArrayLength(env, val);
47321         if (val_constr.datalen > 0)
47322                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47323         else
47324                 val_constr.data = NULL;
47325         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47326         for (size_t g = 0; g < val_constr.datalen; g++) {
47327                 int64_t val_conv_6 = val_vals[g];
47328                 val_constr.data[g] = val_conv_6;
47329         }
47330         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47331         NodeInfo_set_channels(&this_ptr_conv, val_constr);
47332 }
47333
47334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
47335         LDKNodeInfo this_ptr_conv;
47336         this_ptr_conv.inner = untag_ptr(this_ptr);
47337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47339         this_ptr_conv.is_owned = false;
47340         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
47341         int64_t ret_ref = 0;
47342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47344         return ret_ref;
47345 }
47346
47347 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) {
47348         LDKNodeInfo this_ptr_conv;
47349         this_ptr_conv.inner = untag_ptr(this_ptr);
47350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47352         this_ptr_conv.is_owned = false;
47353         LDKRoutingFees val_conv;
47354         val_conv.inner = untag_ptr(val);
47355         val_conv.is_owned = ptr_is_owned(val);
47356         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47357         val_conv = RoutingFees_clone(&val_conv);
47358         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
47359 }
47360
47361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
47362         LDKNodeInfo this_ptr_conv;
47363         this_ptr_conv.inner = untag_ptr(this_ptr);
47364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47366         this_ptr_conv.is_owned = false;
47367         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
47368         int64_t ret_ref = 0;
47369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47371         return ret_ref;
47372 }
47373
47374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47375         LDKNodeInfo this_ptr_conv;
47376         this_ptr_conv.inner = untag_ptr(this_ptr);
47377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47379         this_ptr_conv.is_owned = false;
47380         LDKNodeAnnouncementInfo val_conv;
47381         val_conv.inner = untag_ptr(val);
47382         val_conv.is_owned = ptr_is_owned(val);
47383         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47384         val_conv = NodeAnnouncementInfo_clone(&val_conv);
47385         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
47386 }
47387
47388 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) {
47389         LDKCVec_u64Z channels_arg_constr;
47390         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
47391         if (channels_arg_constr.datalen > 0)
47392                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47393         else
47394                 channels_arg_constr.data = NULL;
47395         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
47396         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
47397                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
47398                 channels_arg_constr.data[g] = channels_arg_conv_6;
47399         }
47400         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
47401         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
47402         lowest_inbound_channel_fees_arg_conv.inner = untag_ptr(lowest_inbound_channel_fees_arg);
47403         lowest_inbound_channel_fees_arg_conv.is_owned = ptr_is_owned(lowest_inbound_channel_fees_arg);
47404         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
47405         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
47406         LDKNodeAnnouncementInfo announcement_info_arg_conv;
47407         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
47408         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
47409         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
47410         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
47411         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
47412         int64_t ret_ref = 0;
47413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47415         return ret_ref;
47416 }
47417
47418 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
47419         LDKNodeInfo ret_var = NodeInfo_clone(arg);
47420         int64_t ret_ref = 0;
47421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47423         return ret_ref;
47424 }
47425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47426         LDKNodeInfo arg_conv;
47427         arg_conv.inner = untag_ptr(arg);
47428         arg_conv.is_owned = ptr_is_owned(arg);
47429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47430         arg_conv.is_owned = false;
47431         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
47432         return ret_conv;
47433 }
47434
47435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47436         LDKNodeInfo orig_conv;
47437         orig_conv.inner = untag_ptr(orig);
47438         orig_conv.is_owned = ptr_is_owned(orig);
47439         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47440         orig_conv.is_owned = false;
47441         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
47442         int64_t ret_ref = 0;
47443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47445         return ret_ref;
47446 }
47447
47448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47449         LDKNodeInfo a_conv;
47450         a_conv.inner = untag_ptr(a);
47451         a_conv.is_owned = ptr_is_owned(a);
47452         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47453         a_conv.is_owned = false;
47454         LDKNodeInfo b_conv;
47455         b_conv.inner = untag_ptr(b);
47456         b_conv.is_owned = ptr_is_owned(b);
47457         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47458         b_conv.is_owned = false;
47459         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
47460         return ret_conv;
47461 }
47462
47463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47464         LDKNodeInfo obj_conv;
47465         obj_conv.inner = untag_ptr(obj);
47466         obj_conv.is_owned = ptr_is_owned(obj);
47467         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47468         obj_conv.is_owned = false;
47469         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
47470         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47471         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47472         CVec_u8Z_free(ret_var);
47473         return ret_arr;
47474 }
47475
47476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47477         LDKu8slice ser_ref;
47478         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47479         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47480         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
47481         *ret_conv = NodeInfo_read(ser_ref);
47482         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47483         return tag_ptr(ret_conv, true);
47484 }
47485
47486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
47487         LDKNetworkGraph obj_conv;
47488         obj_conv.inner = untag_ptr(obj);
47489         obj_conv.is_owned = ptr_is_owned(obj);
47490         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47491         obj_conv.is_owned = false;
47492         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
47493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47495         CVec_u8Z_free(ret_var);
47496         return ret_arr;
47497 }
47498
47499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
47500         LDKu8slice ser_ref;
47501         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47502         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47503         void* arg_ptr = untag_ptr(arg);
47504         CHECK_ACCESS(arg_ptr);
47505         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
47506         if (arg_conv.free == LDKLogger_JCalls_free) {
47507                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47508                 LDKLogger_JCalls_cloned(&arg_conv);
47509         }
47510         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
47511         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
47512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47513         return tag_ptr(ret_conv, true);
47514 }
47515
47516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
47517         LDKThirtyTwoBytes genesis_hash_ref;
47518         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
47519         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
47520         void* logger_ptr = untag_ptr(logger);
47521         CHECK_ACCESS(logger_ptr);
47522         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47523         if (logger_conv.free == LDKLogger_JCalls_free) {
47524                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47525                 LDKLogger_JCalls_cloned(&logger_conv);
47526         }
47527         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
47528         int64_t ret_ref = 0;
47529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47531         return ret_ref;
47532 }
47533
47534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
47535         LDKNetworkGraph this_arg_conv;
47536         this_arg_conv.inner = untag_ptr(this_arg);
47537         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47539         this_arg_conv.is_owned = false;
47540         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
47541         int64_t ret_ref = 0;
47542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47544         return ret_ref;
47545 }
47546
47547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47548         LDKNetworkGraph this_arg_conv;
47549         this_arg_conv.inner = untag_ptr(this_arg);
47550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47552         this_arg_conv.is_owned = false;
47553         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
47554         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
47555         int64_t ret_ref = tag_ptr(ret_copy, true);
47556         return ret_ref;
47557 }
47558
47559 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) {
47560         LDKNetworkGraph this_arg_conv;
47561         this_arg_conv.inner = untag_ptr(this_arg);
47562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47564         this_arg_conv.is_owned = false;
47565         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
47566 }
47567
47568 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) {
47569         LDKNetworkGraph this_arg_conv;
47570         this_arg_conv.inner = untag_ptr(this_arg);
47571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47573         this_arg_conv.is_owned = false;
47574         LDKNodeAnnouncement msg_conv;
47575         msg_conv.inner = untag_ptr(msg);
47576         msg_conv.is_owned = ptr_is_owned(msg);
47577         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47578         msg_conv.is_owned = false;
47579         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47580         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
47581         return tag_ptr(ret_conv, true);
47582 }
47583
47584 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) {
47585         LDKNetworkGraph this_arg_conv;
47586         this_arg_conv.inner = untag_ptr(this_arg);
47587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47589         this_arg_conv.is_owned = false;
47590         LDKUnsignedNodeAnnouncement msg_conv;
47591         msg_conv.inner = untag_ptr(msg);
47592         msg_conv.is_owned = ptr_is_owned(msg);
47593         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47594         msg_conv.is_owned = false;
47595         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47596         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
47597         return tag_ptr(ret_conv, true);
47598 }
47599
47600 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) {
47601         LDKNetworkGraph this_arg_conv;
47602         this_arg_conv.inner = untag_ptr(this_arg);
47603         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47605         this_arg_conv.is_owned = false;
47606         LDKChannelAnnouncement msg_conv;
47607         msg_conv.inner = untag_ptr(msg);
47608         msg_conv.is_owned = ptr_is_owned(msg);
47609         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47610         msg_conv.is_owned = false;
47611         void* chain_access_ptr = untag_ptr(chain_access);
47612         CHECK_ACCESS(chain_access_ptr);
47613         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
47614         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
47615         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
47616                 // Manually implement clone for Java trait instances
47617                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
47618                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47619                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
47620                 }
47621         }
47622         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47623         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
47624         return tag_ptr(ret_conv, true);
47625 }
47626
47627 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) {
47628         LDKNetworkGraph this_arg_conv;
47629         this_arg_conv.inner = untag_ptr(this_arg);
47630         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47632         this_arg_conv.is_owned = false;
47633         LDKUnsignedChannelAnnouncement msg_conv;
47634         msg_conv.inner = untag_ptr(msg);
47635         msg_conv.is_owned = ptr_is_owned(msg);
47636         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47637         msg_conv.is_owned = false;
47638         void* chain_access_ptr = untag_ptr(chain_access);
47639         CHECK_ACCESS(chain_access_ptr);
47640         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
47641         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
47642         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
47643                 // Manually implement clone for Java trait instances
47644                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
47645                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47646                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
47647                 }
47648         }
47649         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47650         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
47651         return tag_ptr(ret_conv, true);
47652 }
47653
47654 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) {
47655         LDKNetworkGraph this_arg_conv;
47656         this_arg_conv.inner = untag_ptr(this_arg);
47657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47659         this_arg_conv.is_owned = false;
47660         LDKChannelFeatures features_conv;
47661         features_conv.inner = untag_ptr(features);
47662         features_conv.is_owned = ptr_is_owned(features);
47663         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
47664         features_conv = ChannelFeatures_clone(&features_conv);
47665         LDKPublicKey node_id_1_ref;
47666         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
47667         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
47668         LDKPublicKey node_id_2_ref;
47669         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
47670         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
47671         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47672         *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);
47673         return tag_ptr(ret_conv, true);
47674 }
47675
47676 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) {
47677         LDKNetworkGraph this_arg_conv;
47678         this_arg_conv.inner = untag_ptr(this_arg);
47679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47681         this_arg_conv.is_owned = false;
47682         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
47683 }
47684
47685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
47686         LDKNetworkGraph this_arg_conv;
47687         this_arg_conv.inner = untag_ptr(this_arg);
47688         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47690         this_arg_conv.is_owned = false;
47691         LDKPublicKey node_id_ref;
47692         CHECK((*env)->GetArrayLength(env, node_id) == 33);
47693         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
47694         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
47695 }
47696
47697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
47698         LDKNetworkGraph this_arg_conv;
47699         this_arg_conv.inner = untag_ptr(this_arg);
47700         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47702         this_arg_conv.is_owned = false;
47703         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
47704 }
47705
47706 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) {
47707         LDKNetworkGraph this_arg_conv;
47708         this_arg_conv.inner = untag_ptr(this_arg);
47709         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47711         this_arg_conv.is_owned = false;
47712         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
47713 }
47714
47715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
47716         LDKNetworkGraph this_arg_conv;
47717         this_arg_conv.inner = untag_ptr(this_arg);
47718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47720         this_arg_conv.is_owned = false;
47721         LDKChannelUpdate msg_conv;
47722         msg_conv.inner = untag_ptr(msg);
47723         msg_conv.is_owned = ptr_is_owned(msg);
47724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47725         msg_conv.is_owned = false;
47726         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47727         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
47728         return tag_ptr(ret_conv, true);
47729 }
47730
47731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
47732         LDKNetworkGraph this_arg_conv;
47733         this_arg_conv.inner = untag_ptr(this_arg);
47734         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47736         this_arg_conv.is_owned = false;
47737         LDKUnsignedChannelUpdate msg_conv;
47738         msg_conv.inner = untag_ptr(msg);
47739         msg_conv.is_owned = ptr_is_owned(msg);
47740         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47741         msg_conv.is_owned = false;
47742         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47743         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
47744         return tag_ptr(ret_conv, true);
47745 }
47746
47747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
47748         LDKReadOnlyNetworkGraph this_arg_conv;
47749         this_arg_conv.inner = untag_ptr(this_arg);
47750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47752         this_arg_conv.is_owned = false;
47753         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
47754         int64_t ret_ref = 0;
47755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47757         return ret_ref;
47758 }
47759
47760 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
47761         LDKReadOnlyNetworkGraph this_arg_conv;
47762         this_arg_conv.inner = untag_ptr(this_arg);
47763         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47765         this_arg_conv.is_owned = false;
47766         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
47767         int64_tArray ret_arr = NULL;
47768         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47769         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47770         for (size_t g = 0; g < ret_var.datalen; g++) {
47771                 int64_t ret_conv_6_conv = ret_var.data[g];
47772                 ret_arr_ptr[g] = ret_conv_6_conv;
47773         }
47774         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47775         FREE(ret_var.data);
47776         return ret_arr;
47777 }
47778
47779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
47780         LDKReadOnlyNetworkGraph this_arg_conv;
47781         this_arg_conv.inner = untag_ptr(this_arg);
47782         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47784         this_arg_conv.is_owned = false;
47785         LDKNodeId node_id_conv;
47786         node_id_conv.inner = untag_ptr(node_id);
47787         node_id_conv.is_owned = ptr_is_owned(node_id);
47788         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47789         node_id_conv.is_owned = false;
47790         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
47791         int64_t ret_ref = 0;
47792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47794         return ret_ref;
47795 }
47796
47797 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
47798         LDKReadOnlyNetworkGraph this_arg_conv;
47799         this_arg_conv.inner = untag_ptr(this_arg);
47800         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47802         this_arg_conv.is_owned = false;
47803         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
47804         int64_tArray ret_arr = NULL;
47805         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47806         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47807         for (size_t i = 0; i < ret_var.datalen; i++) {
47808                 LDKNodeId ret_conv_8_var = ret_var.data[i];
47809                 int64_t ret_conv_8_ref = 0;
47810                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
47811                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
47812                 ret_arr_ptr[i] = ret_conv_8_ref;
47813         }
47814         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47815         FREE(ret_var.data);
47816         return ret_arr;
47817 }
47818
47819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
47820         LDKReadOnlyNetworkGraph this_arg_conv;
47821         this_arg_conv.inner = untag_ptr(this_arg);
47822         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47824         this_arg_conv.is_owned = false;
47825         LDKPublicKey pubkey_ref;
47826         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
47827         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
47828         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
47829         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
47830         int64_t ret_ref = tag_ptr(ret_copy, true);
47831         return ret_ref;
47832 }
47833
47834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47835         LDKDefaultRouter this_obj_conv;
47836         this_obj_conv.inner = untag_ptr(this_obj);
47837         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47839         DefaultRouter_free(this_obj_conv);
47840 }
47841
47842 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) {
47843         LDKNetworkGraph network_graph_conv;
47844         network_graph_conv.inner = untag_ptr(network_graph);
47845         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47846         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47847         network_graph_conv.is_owned = false;
47848         void* logger_ptr = untag_ptr(logger);
47849         CHECK_ACCESS(logger_ptr);
47850         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47851         if (logger_conv.free == LDKLogger_JCalls_free) {
47852                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47853                 LDKLogger_JCalls_cloned(&logger_conv);
47854         }
47855         LDKThirtyTwoBytes random_seed_bytes_ref;
47856         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
47857         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
47858         void* scorer_ptr = untag_ptr(scorer);
47859         CHECK_ACCESS(scorer_ptr);
47860         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
47861         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
47862                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47863                 LDKLockableScore_JCalls_cloned(&scorer_conv);
47864         }
47865         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
47866         int64_t ret_ref = 0;
47867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47868         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47869         return ret_ref;
47870 }
47871
47872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
47873         LDKDefaultRouter this_arg_conv;
47874         this_arg_conv.inner = untag_ptr(this_arg);
47875         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47877         this_arg_conv.is_owned = false;
47878         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
47879         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
47880         return tag_ptr(ret_ret, true);
47881 }
47882
47883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47884         if (!ptr_is_owned(this_ptr)) return;
47885         void* this_ptr_ptr = untag_ptr(this_ptr);
47886         CHECK_ACCESS(this_ptr_ptr);
47887         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
47888         FREE(untag_ptr(this_ptr));
47889         Router_free(this_ptr_conv);
47890 }
47891
47892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47893         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
47894         this_obj_conv.inner = untag_ptr(this_obj);
47895         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47897         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
47898 }
47899
47900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1new(JNIEnv *env, jclass clz, int64_t scorer, int64_t inflight_htlcs) {
47901         void* scorer_ptr = untag_ptr(scorer);
47902         CHECK_ACCESS(scorer_ptr);
47903         LDKScore scorer_conv = *(LDKScore*)(scorer_ptr);
47904         if (scorer_conv.free == LDKScore_JCalls_free) {
47905                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47906                 LDKScore_JCalls_cloned(&scorer_conv);
47907         }
47908         LDKInFlightHtlcs inflight_htlcs_conv;
47909         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
47910         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
47911         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
47912         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
47913         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, inflight_htlcs_conv);
47914         int64_t ret_ref = 0;
47915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47917         return ret_ref;
47918 }
47919
47920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
47921         LDKScorerAccountingForInFlightHtlcs obj_conv;
47922         obj_conv.inner = untag_ptr(obj);
47923         obj_conv.is_owned = ptr_is_owned(obj);
47924         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47925         obj_conv.is_owned = false;
47926         LDKCVec_u8Z ret_var = ScorerAccountingForInFlightHtlcs_write(&obj_conv);
47927         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47928         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47929         CVec_u8Z_free(ret_var);
47930         return ret_arr;
47931 }
47932
47933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
47934         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
47935         this_arg_conv.inner = untag_ptr(this_arg);
47936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47938         this_arg_conv.is_owned = false;
47939         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
47940         *ret_ret = ScorerAccountingForInFlightHtlcs_as_Score(&this_arg_conv);
47941         return tag_ptr(ret_ret, true);
47942 }
47943
47944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47945         LDKInFlightHtlcs this_obj_conv;
47946         this_obj_conv.inner = untag_ptr(this_obj);
47947         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47949         InFlightHtlcs_free(this_obj_conv);
47950 }
47951
47952 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
47953         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
47954         int64_t ret_ref = 0;
47955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47957         return ret_ref;
47958 }
47959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47960         LDKInFlightHtlcs arg_conv;
47961         arg_conv.inner = untag_ptr(arg);
47962         arg_conv.is_owned = ptr_is_owned(arg);
47963         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47964         arg_conv.is_owned = false;
47965         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
47966         return ret_conv;
47967 }
47968
47969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47970         LDKInFlightHtlcs orig_conv;
47971         orig_conv.inner = untag_ptr(orig);
47972         orig_conv.is_owned = ptr_is_owned(orig);
47973         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47974         orig_conv.is_owned = false;
47975         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
47976         int64_t ret_ref = 0;
47977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47979         return ret_ref;
47980 }
47981
47982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1new(JNIEnv *env, jclass clz) {
47983         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
47984         int64_t ret_ref = 0;
47985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47987         return ret_ref;
47988 }
47989
47990 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) {
47991         LDKInFlightHtlcs this_arg_conv;
47992         this_arg_conv.inner = untag_ptr(this_arg);
47993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47995         this_arg_conv.is_owned = false;
47996         LDKNodeId source_conv;
47997         source_conv.inner = untag_ptr(source);
47998         source_conv.is_owned = ptr_is_owned(source);
47999         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
48000         source_conv.is_owned = false;
48001         LDKNodeId target_conv;
48002         target_conv.inner = untag_ptr(target);
48003         target_conv.is_owned = ptr_is_owned(target);
48004         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
48005         target_conv.is_owned = false;
48006         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48007         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
48008         int64_t ret_ref = tag_ptr(ret_copy, true);
48009         return ret_ref;
48010 }
48011
48012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
48013         LDKInFlightHtlcs obj_conv;
48014         obj_conv.inner = untag_ptr(obj);
48015         obj_conv.is_owned = ptr_is_owned(obj);
48016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48017         obj_conv.is_owned = false;
48018         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
48019         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48020         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48021         CVec_u8Z_free(ret_var);
48022         return ret_arr;
48023 }
48024
48025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48026         LDKu8slice ser_ref;
48027         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48028         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48029         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
48030         *ret_conv = InFlightHtlcs_read(ser_ref);
48031         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48032         return tag_ptr(ret_conv, true);
48033 }
48034
48035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48036         LDKRouteHop this_obj_conv;
48037         this_obj_conv.inner = untag_ptr(this_obj);
48038         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48040         RouteHop_free(this_obj_conv);
48041 }
48042
48043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
48044         LDKRouteHop this_ptr_conv;
48045         this_ptr_conv.inner = untag_ptr(this_ptr);
48046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48048         this_ptr_conv.is_owned = false;
48049         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48050         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
48051         return ret_arr;
48052 }
48053
48054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48055         LDKRouteHop this_ptr_conv;
48056         this_ptr_conv.inner = untag_ptr(this_ptr);
48057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48059         this_ptr_conv.is_owned = false;
48060         LDKPublicKey val_ref;
48061         CHECK((*env)->GetArrayLength(env, val) == 33);
48062         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
48063         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
48064 }
48065
48066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48067         LDKRouteHop this_ptr_conv;
48068         this_ptr_conv.inner = untag_ptr(this_ptr);
48069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48071         this_ptr_conv.is_owned = false;
48072         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
48073         int64_t ret_ref = 0;
48074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48076         return ret_ref;
48077 }
48078
48079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48080         LDKRouteHop this_ptr_conv;
48081         this_ptr_conv.inner = untag_ptr(this_ptr);
48082         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48084         this_ptr_conv.is_owned = false;
48085         LDKNodeFeatures val_conv;
48086         val_conv.inner = untag_ptr(val);
48087         val_conv.is_owned = ptr_is_owned(val);
48088         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48089         val_conv = NodeFeatures_clone(&val_conv);
48090         RouteHop_set_node_features(&this_ptr_conv, val_conv);
48091 }
48092
48093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
48094         LDKRouteHop this_ptr_conv;
48095         this_ptr_conv.inner = untag_ptr(this_ptr);
48096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48098         this_ptr_conv.is_owned = false;
48099         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
48100         return ret_conv;
48101 }
48102
48103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48104         LDKRouteHop this_ptr_conv;
48105         this_ptr_conv.inner = untag_ptr(this_ptr);
48106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48108         this_ptr_conv.is_owned = false;
48109         RouteHop_set_short_channel_id(&this_ptr_conv, val);
48110 }
48111
48112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48113         LDKRouteHop this_ptr_conv;
48114         this_ptr_conv.inner = untag_ptr(this_ptr);
48115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48117         this_ptr_conv.is_owned = false;
48118         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
48119         int64_t ret_ref = 0;
48120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48121         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48122         return ret_ref;
48123 }
48124
48125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48126         LDKRouteHop this_ptr_conv;
48127         this_ptr_conv.inner = untag_ptr(this_ptr);
48128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48130         this_ptr_conv.is_owned = false;
48131         LDKChannelFeatures val_conv;
48132         val_conv.inner = untag_ptr(val);
48133         val_conv.is_owned = ptr_is_owned(val);
48134         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48135         val_conv = ChannelFeatures_clone(&val_conv);
48136         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
48137 }
48138
48139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48140         LDKRouteHop this_ptr_conv;
48141         this_ptr_conv.inner = untag_ptr(this_ptr);
48142         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48144         this_ptr_conv.is_owned = false;
48145         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
48146         return ret_conv;
48147 }
48148
48149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48150         LDKRouteHop this_ptr_conv;
48151         this_ptr_conv.inner = untag_ptr(this_ptr);
48152         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48154         this_ptr_conv.is_owned = false;
48155         RouteHop_set_fee_msat(&this_ptr_conv, val);
48156 }
48157
48158 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48159         LDKRouteHop this_ptr_conv;
48160         this_ptr_conv.inner = untag_ptr(this_ptr);
48161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48163         this_ptr_conv.is_owned = false;
48164         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
48165         return ret_conv;
48166 }
48167
48168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48169         LDKRouteHop this_ptr_conv;
48170         this_ptr_conv.inner = untag_ptr(this_ptr);
48171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48173         this_ptr_conv.is_owned = false;
48174         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
48175 }
48176
48177 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) {
48178         LDKPublicKey pubkey_arg_ref;
48179         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
48180         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
48181         LDKNodeFeatures node_features_arg_conv;
48182         node_features_arg_conv.inner = untag_ptr(node_features_arg);
48183         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
48184         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
48185         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
48186         LDKChannelFeatures channel_features_arg_conv;
48187         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
48188         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
48189         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
48190         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
48191         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);
48192         int64_t ret_ref = 0;
48193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48195         return ret_ref;
48196 }
48197
48198 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
48199         LDKRouteHop ret_var = RouteHop_clone(arg);
48200         int64_t ret_ref = 0;
48201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48203         return ret_ref;
48204 }
48205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48206         LDKRouteHop arg_conv;
48207         arg_conv.inner = untag_ptr(arg);
48208         arg_conv.is_owned = ptr_is_owned(arg);
48209         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48210         arg_conv.is_owned = false;
48211         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
48212         return ret_conv;
48213 }
48214
48215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48216         LDKRouteHop orig_conv;
48217         orig_conv.inner = untag_ptr(orig);
48218         orig_conv.is_owned = ptr_is_owned(orig);
48219         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48220         orig_conv.is_owned = false;
48221         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
48222         int64_t ret_ref = 0;
48223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48225         return ret_ref;
48226 }
48227
48228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
48229         LDKRouteHop o_conv;
48230         o_conv.inner = untag_ptr(o);
48231         o_conv.is_owned = ptr_is_owned(o);
48232         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48233         o_conv.is_owned = false;
48234         int64_t ret_conv = RouteHop_hash(&o_conv);
48235         return ret_conv;
48236 }
48237
48238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48239         LDKRouteHop a_conv;
48240         a_conv.inner = untag_ptr(a);
48241         a_conv.is_owned = ptr_is_owned(a);
48242         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48243         a_conv.is_owned = false;
48244         LDKRouteHop b_conv;
48245         b_conv.inner = untag_ptr(b);
48246         b_conv.is_owned = ptr_is_owned(b);
48247         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48248         b_conv.is_owned = false;
48249         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
48250         return ret_conv;
48251 }
48252
48253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
48254         LDKRouteHop obj_conv;
48255         obj_conv.inner = untag_ptr(obj);
48256         obj_conv.is_owned = ptr_is_owned(obj);
48257         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48258         obj_conv.is_owned = false;
48259         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
48260         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48261         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48262         CVec_u8Z_free(ret_var);
48263         return ret_arr;
48264 }
48265
48266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48267         LDKu8slice ser_ref;
48268         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48269         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48270         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
48271         *ret_conv = RouteHop_read(ser_ref);
48272         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48273         return tag_ptr(ret_conv, true);
48274 }
48275
48276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48277         LDKRoute this_obj_conv;
48278         this_obj_conv.inner = untag_ptr(this_obj);
48279         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48281         Route_free(this_obj_conv);
48282 }
48283
48284 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
48285         LDKRoute this_ptr_conv;
48286         this_ptr_conv.inner = untag_ptr(this_ptr);
48287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48289         this_ptr_conv.is_owned = false;
48290         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
48291         jobjectArray ret_arr = NULL;
48292         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
48293         ;
48294         for (size_t m = 0; m < ret_var.datalen; m++) {
48295                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
48296                 int64_tArray ret_conv_12_arr = NULL;
48297                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
48298                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
48299                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
48300                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
48301                         int64_t ret_conv_12_conv_10_ref = 0;
48302                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
48303                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
48304                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
48305                 }
48306                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
48307                 FREE(ret_conv_12_var.data);
48308                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
48309         }
48310         
48311         FREE(ret_var.data);
48312         return ret_arr;
48313 }
48314
48315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
48316         LDKRoute this_ptr_conv;
48317         this_ptr_conv.inner = untag_ptr(this_ptr);
48318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48320         this_ptr_conv.is_owned = false;
48321         LDKCVec_CVec_RouteHopZZ val_constr;
48322         val_constr.datalen = (*env)->GetArrayLength(env, val);
48323         if (val_constr.datalen > 0)
48324                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
48325         else
48326                 val_constr.data = NULL;
48327         for (size_t m = 0; m < val_constr.datalen; m++) {
48328                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
48329                 LDKCVec_RouteHopZ val_conv_12_constr;
48330                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
48331                 if (val_conv_12_constr.datalen > 0)
48332                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
48333                 else
48334                         val_conv_12_constr.data = NULL;
48335                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
48336                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
48337                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
48338                         LDKRouteHop val_conv_12_conv_10_conv;
48339                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
48340                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
48341                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
48342                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
48343                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
48344                 }
48345                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
48346                 val_constr.data[m] = val_conv_12_constr;
48347         }
48348         Route_set_paths(&this_ptr_conv, val_constr);
48349 }
48350
48351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
48352         LDKRoute this_ptr_conv;
48353         this_ptr_conv.inner = untag_ptr(this_ptr);
48354         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48356         this_ptr_conv.is_owned = false;
48357         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
48358         int64_t ret_ref = 0;
48359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48361         return ret_ref;
48362 }
48363
48364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48365         LDKRoute this_ptr_conv;
48366         this_ptr_conv.inner = untag_ptr(this_ptr);
48367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48369         this_ptr_conv.is_owned = false;
48370         LDKPaymentParameters val_conv;
48371         val_conv.inner = untag_ptr(val);
48372         val_conv.is_owned = ptr_is_owned(val);
48373         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48374         val_conv = PaymentParameters_clone(&val_conv);
48375         Route_set_payment_params(&this_ptr_conv, val_conv);
48376 }
48377
48378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
48379         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
48380         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
48381         if (paths_arg_constr.datalen > 0)
48382                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
48383         else
48384                 paths_arg_constr.data = NULL;
48385         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
48386                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
48387                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
48388                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
48389                 if (paths_arg_conv_12_constr.datalen > 0)
48390                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
48391                 else
48392                         paths_arg_conv_12_constr.data = NULL;
48393                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
48394                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
48395                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
48396                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
48397                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
48398                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
48399                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
48400                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
48401                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
48402                 }
48403                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
48404                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
48405         }
48406         LDKPaymentParameters payment_params_arg_conv;
48407         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
48408         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
48409         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
48410         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
48411         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
48412         int64_t ret_ref = 0;
48413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48415         return ret_ref;
48416 }
48417
48418 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
48419         LDKRoute ret_var = Route_clone(arg);
48420         int64_t ret_ref = 0;
48421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48423         return ret_ref;
48424 }
48425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48426         LDKRoute arg_conv;
48427         arg_conv.inner = untag_ptr(arg);
48428         arg_conv.is_owned = ptr_is_owned(arg);
48429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48430         arg_conv.is_owned = false;
48431         int64_t ret_conv = Route_clone_ptr(&arg_conv);
48432         return ret_conv;
48433 }
48434
48435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48436         LDKRoute orig_conv;
48437         orig_conv.inner = untag_ptr(orig);
48438         orig_conv.is_owned = ptr_is_owned(orig);
48439         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48440         orig_conv.is_owned = false;
48441         LDKRoute ret_var = Route_clone(&orig_conv);
48442         int64_t ret_ref = 0;
48443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48445         return ret_ref;
48446 }
48447
48448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
48449         LDKRoute o_conv;
48450         o_conv.inner = untag_ptr(o);
48451         o_conv.is_owned = ptr_is_owned(o);
48452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48453         o_conv.is_owned = false;
48454         int64_t ret_conv = Route_hash(&o_conv);
48455         return ret_conv;
48456 }
48457
48458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48459         LDKRoute a_conv;
48460         a_conv.inner = untag_ptr(a);
48461         a_conv.is_owned = ptr_is_owned(a);
48462         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48463         a_conv.is_owned = false;
48464         LDKRoute b_conv;
48465         b_conv.inner = untag_ptr(b);
48466         b_conv.is_owned = ptr_is_owned(b);
48467         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48468         b_conv.is_owned = false;
48469         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
48470         return ret_conv;
48471 }
48472
48473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
48474         LDKRoute this_arg_conv;
48475         this_arg_conv.inner = untag_ptr(this_arg);
48476         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48478         this_arg_conv.is_owned = false;
48479         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
48480         return ret_conv;
48481 }
48482
48483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
48484         LDKRoute this_arg_conv;
48485         this_arg_conv.inner = untag_ptr(this_arg);
48486         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48488         this_arg_conv.is_owned = false;
48489         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
48490         return ret_conv;
48491 }
48492
48493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
48494         LDKRoute obj_conv;
48495         obj_conv.inner = untag_ptr(obj);
48496         obj_conv.is_owned = ptr_is_owned(obj);
48497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48498         obj_conv.is_owned = false;
48499         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
48500         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48501         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48502         CVec_u8Z_free(ret_var);
48503         return ret_arr;
48504 }
48505
48506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48507         LDKu8slice ser_ref;
48508         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48509         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48510         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
48511         *ret_conv = Route_read(ser_ref);
48512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48513         return tag_ptr(ret_conv, true);
48514 }
48515
48516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48517         LDKRouteParameters this_obj_conv;
48518         this_obj_conv.inner = untag_ptr(this_obj);
48519         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48521         RouteParameters_free(this_obj_conv);
48522 }
48523
48524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
48525         LDKRouteParameters this_ptr_conv;
48526         this_ptr_conv.inner = untag_ptr(this_ptr);
48527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48529         this_ptr_conv.is_owned = false;
48530         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
48531         int64_t ret_ref = 0;
48532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48534         return ret_ref;
48535 }
48536
48537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48538         LDKRouteParameters this_ptr_conv;
48539         this_ptr_conv.inner = untag_ptr(this_ptr);
48540         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48542         this_ptr_conv.is_owned = false;
48543         LDKPaymentParameters val_conv;
48544         val_conv.inner = untag_ptr(val);
48545         val_conv.is_owned = ptr_is_owned(val);
48546         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48547         val_conv = PaymentParameters_clone(&val_conv);
48548         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
48549 }
48550
48551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48552         LDKRouteParameters this_ptr_conv;
48553         this_ptr_conv.inner = untag_ptr(this_ptr);
48554         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48556         this_ptr_conv.is_owned = false;
48557         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
48558         return ret_conv;
48559 }
48560
48561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48562         LDKRouteParameters this_ptr_conv;
48563         this_ptr_conv.inner = untag_ptr(this_ptr);
48564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48566         this_ptr_conv.is_owned = false;
48567         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
48568 }
48569
48570 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48571         LDKRouteParameters this_ptr_conv;
48572         this_ptr_conv.inner = untag_ptr(this_ptr);
48573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48575         this_ptr_conv.is_owned = false;
48576         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
48577         return ret_conv;
48578 }
48579
48580 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) {
48581         LDKRouteParameters this_ptr_conv;
48582         this_ptr_conv.inner = untag_ptr(this_ptr);
48583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48585         this_ptr_conv.is_owned = false;
48586         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
48587 }
48588
48589 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) {
48590         LDKPaymentParameters payment_params_arg_conv;
48591         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
48592         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
48593         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
48594         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
48595         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
48596         int64_t ret_ref = 0;
48597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48599         return ret_ref;
48600 }
48601
48602 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
48603         LDKRouteParameters ret_var = RouteParameters_clone(arg);
48604         int64_t ret_ref = 0;
48605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48606         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48607         return ret_ref;
48608 }
48609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48610         LDKRouteParameters arg_conv;
48611         arg_conv.inner = untag_ptr(arg);
48612         arg_conv.is_owned = ptr_is_owned(arg);
48613         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48614         arg_conv.is_owned = false;
48615         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
48616         return ret_conv;
48617 }
48618
48619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48620         LDKRouteParameters orig_conv;
48621         orig_conv.inner = untag_ptr(orig);
48622         orig_conv.is_owned = ptr_is_owned(orig);
48623         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48624         orig_conv.is_owned = false;
48625         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
48626         int64_t ret_ref = 0;
48627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48629         return ret_ref;
48630 }
48631
48632 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
48633         LDKRouteParameters obj_conv;
48634         obj_conv.inner = untag_ptr(obj);
48635         obj_conv.is_owned = ptr_is_owned(obj);
48636         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48637         obj_conv.is_owned = false;
48638         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
48639         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48640         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48641         CVec_u8Z_free(ret_var);
48642         return ret_arr;
48643 }
48644
48645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48646         LDKu8slice ser_ref;
48647         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48648         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48649         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
48650         *ret_conv = RouteParameters_read(ser_ref);
48651         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48652         return tag_ptr(ret_conv, true);
48653 }
48654
48655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48656         LDKPaymentParameters this_obj_conv;
48657         this_obj_conv.inner = untag_ptr(this_obj);
48658         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48660         PaymentParameters_free(this_obj_conv);
48661 }
48662
48663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
48664         LDKPaymentParameters this_ptr_conv;
48665         this_ptr_conv.inner = untag_ptr(this_ptr);
48666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48668         this_ptr_conv.is_owned = false;
48669         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48670         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
48671         return ret_arr;
48672 }
48673
48674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48675         LDKPaymentParameters this_ptr_conv;
48676         this_ptr_conv.inner = untag_ptr(this_ptr);
48677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48679         this_ptr_conv.is_owned = false;
48680         LDKPublicKey val_ref;
48681         CHECK((*env)->GetArrayLength(env, val) == 33);
48682         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
48683         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
48684 }
48685
48686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48687         LDKPaymentParameters this_ptr_conv;
48688         this_ptr_conv.inner = untag_ptr(this_ptr);
48689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48691         this_ptr_conv.is_owned = false;
48692         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
48693         int64_t ret_ref = 0;
48694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48696         return ret_ref;
48697 }
48698
48699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48700         LDKPaymentParameters this_ptr_conv;
48701         this_ptr_conv.inner = untag_ptr(this_ptr);
48702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48704         this_ptr_conv.is_owned = false;
48705         LDKInvoiceFeatures val_conv;
48706         val_conv.inner = untag_ptr(val);
48707         val_conv.is_owned = ptr_is_owned(val);
48708         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48709         val_conv = InvoiceFeatures_clone(&val_conv);
48710         PaymentParameters_set_features(&this_ptr_conv, val_conv);
48711 }
48712
48713 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
48714         LDKPaymentParameters this_ptr_conv;
48715         this_ptr_conv.inner = untag_ptr(this_ptr);
48716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48718         this_ptr_conv.is_owned = false;
48719         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
48720         int64_tArray ret_arr = NULL;
48721         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48722         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48723         for (size_t l = 0; l < ret_var.datalen; l++) {
48724                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
48725                 int64_t ret_conv_11_ref = 0;
48726                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
48727                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
48728                 ret_arr_ptr[l] = ret_conv_11_ref;
48729         }
48730         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48731         FREE(ret_var.data);
48732         return ret_arr;
48733 }
48734
48735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
48736         LDKPaymentParameters this_ptr_conv;
48737         this_ptr_conv.inner = untag_ptr(this_ptr);
48738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48740         this_ptr_conv.is_owned = false;
48741         LDKCVec_RouteHintZ val_constr;
48742         val_constr.datalen = (*env)->GetArrayLength(env, val);
48743         if (val_constr.datalen > 0)
48744                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
48745         else
48746                 val_constr.data = NULL;
48747         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
48748         for (size_t l = 0; l < val_constr.datalen; l++) {
48749                 int64_t val_conv_11 = val_vals[l];
48750                 LDKRouteHint val_conv_11_conv;
48751                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
48752                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
48753                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
48754                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
48755                 val_constr.data[l] = val_conv_11_conv;
48756         }
48757         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
48758         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
48759 }
48760
48761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
48762         LDKPaymentParameters this_ptr_conv;
48763         this_ptr_conv.inner = untag_ptr(this_ptr);
48764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48766         this_ptr_conv.is_owned = false;
48767         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48768         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
48769         int64_t ret_ref = tag_ptr(ret_copy, true);
48770         return ret_ref;
48771 }
48772
48773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48774         LDKPaymentParameters this_ptr_conv;
48775         this_ptr_conv.inner = untag_ptr(this_ptr);
48776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48778         this_ptr_conv.is_owned = false;
48779         void* val_ptr = untag_ptr(val);
48780         CHECK_ACCESS(val_ptr);
48781         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
48782         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
48783         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
48784 }
48785
48786 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48787         LDKPaymentParameters this_ptr_conv;
48788         this_ptr_conv.inner = untag_ptr(this_ptr);
48789         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48791         this_ptr_conv.is_owned = false;
48792         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
48793         return ret_conv;
48794 }
48795
48796 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) {
48797         LDKPaymentParameters this_ptr_conv;
48798         this_ptr_conv.inner = untag_ptr(this_ptr);
48799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48801         this_ptr_conv.is_owned = false;
48802         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
48803 }
48804
48805 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
48806         LDKPaymentParameters this_ptr_conv;
48807         this_ptr_conv.inner = untag_ptr(this_ptr);
48808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48810         this_ptr_conv.is_owned = false;
48811         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
48812         return ret_conv;
48813 }
48814
48815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
48816         LDKPaymentParameters this_ptr_conv;
48817         this_ptr_conv.inner = untag_ptr(this_ptr);
48818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48820         this_ptr_conv.is_owned = false;
48821         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
48822 }
48823
48824 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) {
48825         LDKPaymentParameters this_ptr_conv;
48826         this_ptr_conv.inner = untag_ptr(this_ptr);
48827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48829         this_ptr_conv.is_owned = false;
48830         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
48831         return ret_conv;
48832 }
48833
48834 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) {
48835         LDKPaymentParameters this_ptr_conv;
48836         this_ptr_conv.inner = untag_ptr(this_ptr);
48837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48839         this_ptr_conv.is_owned = false;
48840         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
48841 }
48842
48843 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
48844         LDKPaymentParameters this_ptr_conv;
48845         this_ptr_conv.inner = untag_ptr(this_ptr);
48846         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48848         this_ptr_conv.is_owned = false;
48849         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
48850         int64_tArray ret_arr = NULL;
48851         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48852         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48853         for (size_t g = 0; g < ret_var.datalen; g++) {
48854                 int64_t ret_conv_6_conv = ret_var.data[g];
48855                 ret_arr_ptr[g] = ret_conv_6_conv;
48856         }
48857         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48858         FREE(ret_var.data);
48859         return ret_arr;
48860 }
48861
48862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
48863         LDKPaymentParameters this_ptr_conv;
48864         this_ptr_conv.inner = untag_ptr(this_ptr);
48865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48867         this_ptr_conv.is_owned = false;
48868         LDKCVec_u64Z val_constr;
48869         val_constr.datalen = (*env)->GetArrayLength(env, val);
48870         if (val_constr.datalen > 0)
48871                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
48872         else
48873                 val_constr.data = NULL;
48874         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
48875         for (size_t g = 0; g < val_constr.datalen; g++) {
48876                 int64_t val_conv_6 = val_vals[g];
48877                 val_constr.data[g] = val_conv_6;
48878         }
48879         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
48880         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
48881 }
48882
48883 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) {
48884         LDKPublicKey payee_pubkey_arg_ref;
48885         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
48886         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
48887         LDKInvoiceFeatures features_arg_conv;
48888         features_arg_conv.inner = untag_ptr(features_arg);
48889         features_arg_conv.is_owned = ptr_is_owned(features_arg);
48890         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
48891         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
48892         LDKCVec_RouteHintZ route_hints_arg_constr;
48893         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
48894         if (route_hints_arg_constr.datalen > 0)
48895                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
48896         else
48897                 route_hints_arg_constr.data = NULL;
48898         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
48899         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
48900                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
48901                 LDKRouteHint route_hints_arg_conv_11_conv;
48902                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
48903                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
48904                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
48905                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
48906                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
48907         }
48908         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
48909         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
48910         CHECK_ACCESS(expiry_time_arg_ptr);
48911         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
48912         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
48913         LDKCVec_u64Z previously_failed_channels_arg_constr;
48914         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
48915         if (previously_failed_channels_arg_constr.datalen > 0)
48916                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
48917         else
48918                 previously_failed_channels_arg_constr.data = NULL;
48919         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
48920         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
48921                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
48922                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
48923         }
48924         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
48925         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);
48926         int64_t ret_ref = 0;
48927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48929         return ret_ref;
48930 }
48931
48932 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
48933         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
48934         int64_t ret_ref = 0;
48935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48937         return ret_ref;
48938 }
48939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48940         LDKPaymentParameters arg_conv;
48941         arg_conv.inner = untag_ptr(arg);
48942         arg_conv.is_owned = ptr_is_owned(arg);
48943         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48944         arg_conv.is_owned = false;
48945         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
48946         return ret_conv;
48947 }
48948
48949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48950         LDKPaymentParameters orig_conv;
48951         orig_conv.inner = untag_ptr(orig);
48952         orig_conv.is_owned = ptr_is_owned(orig);
48953         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48954         orig_conv.is_owned = false;
48955         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
48956         int64_t ret_ref = 0;
48957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48959         return ret_ref;
48960 }
48961
48962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
48963         LDKPaymentParameters o_conv;
48964         o_conv.inner = untag_ptr(o);
48965         o_conv.is_owned = ptr_is_owned(o);
48966         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48967         o_conv.is_owned = false;
48968         int64_t ret_conv = PaymentParameters_hash(&o_conv);
48969         return ret_conv;
48970 }
48971
48972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48973         LDKPaymentParameters a_conv;
48974         a_conv.inner = untag_ptr(a);
48975         a_conv.is_owned = ptr_is_owned(a);
48976         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48977         a_conv.is_owned = false;
48978         LDKPaymentParameters b_conv;
48979         b_conv.inner = untag_ptr(b);
48980         b_conv.is_owned = ptr_is_owned(b);
48981         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48982         b_conv.is_owned = false;
48983         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
48984         return ret_conv;
48985 }
48986
48987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
48988         LDKPaymentParameters obj_conv;
48989         obj_conv.inner = untag_ptr(obj);
48990         obj_conv.is_owned = ptr_is_owned(obj);
48991         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48992         obj_conv.is_owned = false;
48993         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
48994         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48995         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48996         CVec_u8Z_free(ret_var);
48997         return ret_arr;
48998 }
48999
49000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49001         LDKu8slice ser_ref;
49002         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49003         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49004         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
49005         *ret_conv = PaymentParameters_read(ser_ref);
49006         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49007         return tag_ptr(ret_conv, true);
49008 }
49009
49010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
49011         LDKPublicKey payee_pubkey_ref;
49012         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
49013         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
49014         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
49015         int64_t ret_ref = 0;
49016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49017         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49018         return ret_ref;
49019 }
49020
49021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
49022         LDKPublicKey payee_pubkey_ref;
49023         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
49024         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
49025         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
49026         int64_t ret_ref = 0;
49027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49028         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49029         return ret_ref;
49030 }
49031
49032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49033         LDKRouteHint this_obj_conv;
49034         this_obj_conv.inner = untag_ptr(this_obj);
49035         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49037         RouteHint_free(this_obj_conv);
49038 }
49039
49040 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
49041         LDKRouteHint this_ptr_conv;
49042         this_ptr_conv.inner = untag_ptr(this_ptr);
49043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49045         this_ptr_conv.is_owned = false;
49046         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
49047         int64_tArray ret_arr = NULL;
49048         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49049         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49050         for (size_t o = 0; o < ret_var.datalen; o++) {
49051                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
49052                 int64_t ret_conv_14_ref = 0;
49053                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
49054                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
49055                 ret_arr_ptr[o] = ret_conv_14_ref;
49056         }
49057         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49058         FREE(ret_var.data);
49059         return ret_arr;
49060 }
49061
49062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
49063         LDKRouteHint this_ptr_conv;
49064         this_ptr_conv.inner = untag_ptr(this_ptr);
49065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49067         this_ptr_conv.is_owned = false;
49068         LDKCVec_RouteHintHopZ val_constr;
49069         val_constr.datalen = (*env)->GetArrayLength(env, val);
49070         if (val_constr.datalen > 0)
49071                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
49072         else
49073                 val_constr.data = NULL;
49074         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
49075         for (size_t o = 0; o < val_constr.datalen; o++) {
49076                 int64_t val_conv_14 = val_vals[o];
49077                 LDKRouteHintHop val_conv_14_conv;
49078                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
49079                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
49080                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
49081                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
49082                 val_constr.data[o] = val_conv_14_conv;
49083         }
49084         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
49085         RouteHint_set_a(&this_ptr_conv, val_constr);
49086 }
49087
49088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
49089         LDKCVec_RouteHintHopZ a_arg_constr;
49090         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
49091         if (a_arg_constr.datalen > 0)
49092                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
49093         else
49094                 a_arg_constr.data = NULL;
49095         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
49096         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
49097                 int64_t a_arg_conv_14 = a_arg_vals[o];
49098                 LDKRouteHintHop a_arg_conv_14_conv;
49099                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
49100                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
49101                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
49102                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
49103                 a_arg_constr.data[o] = a_arg_conv_14_conv;
49104         }
49105         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
49106         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
49107         int64_t ret_ref = 0;
49108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49110         return ret_ref;
49111 }
49112
49113 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
49114         LDKRouteHint ret_var = RouteHint_clone(arg);
49115         int64_t ret_ref = 0;
49116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49117         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49118         return ret_ref;
49119 }
49120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49121         LDKRouteHint arg_conv;
49122         arg_conv.inner = untag_ptr(arg);
49123         arg_conv.is_owned = ptr_is_owned(arg);
49124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49125         arg_conv.is_owned = false;
49126         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
49127         return ret_conv;
49128 }
49129
49130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49131         LDKRouteHint orig_conv;
49132         orig_conv.inner = untag_ptr(orig);
49133         orig_conv.is_owned = ptr_is_owned(orig);
49134         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49135         orig_conv.is_owned = false;
49136         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
49137         int64_t ret_ref = 0;
49138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49140         return ret_ref;
49141 }
49142
49143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
49144         LDKRouteHint o_conv;
49145         o_conv.inner = untag_ptr(o);
49146         o_conv.is_owned = ptr_is_owned(o);
49147         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49148         o_conv.is_owned = false;
49149         int64_t ret_conv = RouteHint_hash(&o_conv);
49150         return ret_conv;
49151 }
49152
49153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49154         LDKRouteHint a_conv;
49155         a_conv.inner = untag_ptr(a);
49156         a_conv.is_owned = ptr_is_owned(a);
49157         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49158         a_conv.is_owned = false;
49159         LDKRouteHint b_conv;
49160         b_conv.inner = untag_ptr(b);
49161         b_conv.is_owned = ptr_is_owned(b);
49162         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49163         b_conv.is_owned = false;
49164         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
49165         return ret_conv;
49166 }
49167
49168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
49169         LDKRouteHint obj_conv;
49170         obj_conv.inner = untag_ptr(obj);
49171         obj_conv.is_owned = ptr_is_owned(obj);
49172         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49173         obj_conv.is_owned = false;
49174         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
49175         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49176         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49177         CVec_u8Z_free(ret_var);
49178         return ret_arr;
49179 }
49180
49181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49182         LDKu8slice ser_ref;
49183         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49184         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49185         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
49186         *ret_conv = RouteHint_read(ser_ref);
49187         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49188         return tag_ptr(ret_conv, true);
49189 }
49190
49191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49192         LDKRouteHintHop this_obj_conv;
49193         this_obj_conv.inner = untag_ptr(this_obj);
49194         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49196         RouteHintHop_free(this_obj_conv);
49197 }
49198
49199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
49200         LDKRouteHintHop this_ptr_conv;
49201         this_ptr_conv.inner = untag_ptr(this_ptr);
49202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49204         this_ptr_conv.is_owned = false;
49205         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
49206         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
49207         return ret_arr;
49208 }
49209
49210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49211         LDKRouteHintHop this_ptr_conv;
49212         this_ptr_conv.inner = untag_ptr(this_ptr);
49213         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49215         this_ptr_conv.is_owned = false;
49216         LDKPublicKey val_ref;
49217         CHECK((*env)->GetArrayLength(env, val) == 33);
49218         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
49219         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
49220 }
49221
49222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
49223         LDKRouteHintHop this_ptr_conv;
49224         this_ptr_conv.inner = untag_ptr(this_ptr);
49225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49227         this_ptr_conv.is_owned = false;
49228         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
49229         return ret_conv;
49230 }
49231
49232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49233         LDKRouteHintHop this_ptr_conv;
49234         this_ptr_conv.inner = untag_ptr(this_ptr);
49235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49237         this_ptr_conv.is_owned = false;
49238         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
49239 }
49240
49241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
49242         LDKRouteHintHop this_ptr_conv;
49243         this_ptr_conv.inner = untag_ptr(this_ptr);
49244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49246         this_ptr_conv.is_owned = false;
49247         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
49248         int64_t ret_ref = 0;
49249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49251         return ret_ref;
49252 }
49253
49254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49255         LDKRouteHintHop this_ptr_conv;
49256         this_ptr_conv.inner = untag_ptr(this_ptr);
49257         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49259         this_ptr_conv.is_owned = false;
49260         LDKRoutingFees val_conv;
49261         val_conv.inner = untag_ptr(val);
49262         val_conv.is_owned = ptr_is_owned(val);
49263         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49264         val_conv = RoutingFees_clone(&val_conv);
49265         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
49266 }
49267
49268 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
49269         LDKRouteHintHop this_ptr_conv;
49270         this_ptr_conv.inner = untag_ptr(this_ptr);
49271         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49273         this_ptr_conv.is_owned = false;
49274         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
49275         return ret_conv;
49276 }
49277
49278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
49279         LDKRouteHintHop this_ptr_conv;
49280         this_ptr_conv.inner = untag_ptr(this_ptr);
49281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49283         this_ptr_conv.is_owned = false;
49284         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
49285 }
49286
49287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49288         LDKRouteHintHop this_ptr_conv;
49289         this_ptr_conv.inner = untag_ptr(this_ptr);
49290         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49292         this_ptr_conv.is_owned = false;
49293         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49294         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
49295         int64_t ret_ref = tag_ptr(ret_copy, true);
49296         return ret_ref;
49297 }
49298
49299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49300         LDKRouteHintHop this_ptr_conv;
49301         this_ptr_conv.inner = untag_ptr(this_ptr);
49302         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49304         this_ptr_conv.is_owned = false;
49305         void* val_ptr = untag_ptr(val);
49306         CHECK_ACCESS(val_ptr);
49307         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49308         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49309         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
49310 }
49311
49312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49313         LDKRouteHintHop this_ptr_conv;
49314         this_ptr_conv.inner = untag_ptr(this_ptr);
49315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49317         this_ptr_conv.is_owned = false;
49318         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49319         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
49320         int64_t ret_ref = tag_ptr(ret_copy, true);
49321         return ret_ref;
49322 }
49323
49324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49325         LDKRouteHintHop this_ptr_conv;
49326         this_ptr_conv.inner = untag_ptr(this_ptr);
49327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49329         this_ptr_conv.is_owned = false;
49330         void* val_ptr = untag_ptr(val);
49331         CHECK_ACCESS(val_ptr);
49332         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49333         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49334         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
49335 }
49336
49337 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) {
49338         LDKPublicKey src_node_id_arg_ref;
49339         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
49340         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
49341         LDKRoutingFees fees_arg_conv;
49342         fees_arg_conv.inner = untag_ptr(fees_arg);
49343         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
49344         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
49345         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
49346         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
49347         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
49348         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
49349         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
49350         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
49351         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
49352         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
49353         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
49354         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);
49355         int64_t ret_ref = 0;
49356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49358         return ret_ref;
49359 }
49360
49361 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
49362         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
49363         int64_t ret_ref = 0;
49364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49366         return ret_ref;
49367 }
49368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49369         LDKRouteHintHop arg_conv;
49370         arg_conv.inner = untag_ptr(arg);
49371         arg_conv.is_owned = ptr_is_owned(arg);
49372         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49373         arg_conv.is_owned = false;
49374         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
49375         return ret_conv;
49376 }
49377
49378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49379         LDKRouteHintHop orig_conv;
49380         orig_conv.inner = untag_ptr(orig);
49381         orig_conv.is_owned = ptr_is_owned(orig);
49382         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49383         orig_conv.is_owned = false;
49384         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
49385         int64_t ret_ref = 0;
49386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49388         return ret_ref;
49389 }
49390
49391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
49392         LDKRouteHintHop o_conv;
49393         o_conv.inner = untag_ptr(o);
49394         o_conv.is_owned = ptr_is_owned(o);
49395         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49396         o_conv.is_owned = false;
49397         int64_t ret_conv = RouteHintHop_hash(&o_conv);
49398         return ret_conv;
49399 }
49400
49401 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49402         LDKRouteHintHop a_conv;
49403         a_conv.inner = untag_ptr(a);
49404         a_conv.is_owned = ptr_is_owned(a);
49405         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49406         a_conv.is_owned = false;
49407         LDKRouteHintHop b_conv;
49408         b_conv.inner = untag_ptr(b);
49409         b_conv.is_owned = ptr_is_owned(b);
49410         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49411         b_conv.is_owned = false;
49412         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
49413         return ret_conv;
49414 }
49415
49416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
49417         LDKRouteHintHop obj_conv;
49418         obj_conv.inner = untag_ptr(obj);
49419         obj_conv.is_owned = ptr_is_owned(obj);
49420         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49421         obj_conv.is_owned = false;
49422         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
49423         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49424         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49425         CVec_u8Z_free(ret_var);
49426         return ret_arr;
49427 }
49428
49429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49430         LDKu8slice ser_ref;
49431         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49432         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49433         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
49434         *ret_conv = RouteHintHop_read(ser_ref);
49435         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49436         return tag_ptr(ret_conv, true);
49437 }
49438
49439 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) {
49440         LDKPublicKey our_node_pubkey_ref;
49441         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
49442         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
49443         LDKRouteParameters route_params_conv;
49444         route_params_conv.inner = untag_ptr(route_params);
49445         route_params_conv.is_owned = ptr_is_owned(route_params);
49446         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
49447         route_params_conv.is_owned = false;
49448         LDKNetworkGraph network_graph_conv;
49449         network_graph_conv.inner = untag_ptr(network_graph);
49450         network_graph_conv.is_owned = ptr_is_owned(network_graph);
49451         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49452         network_graph_conv.is_owned = false;
49453         LDKCVec_ChannelDetailsZ first_hops_constr;
49454         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
49455         if (first_hops != NULL) {
49456                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
49457                 if (first_hops_constr.datalen > 0)
49458                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
49459                 else
49460                         first_hops_constr.data = NULL;
49461                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
49462                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
49463                         int64_t first_hops_conv_16 = first_hops_vals[q];
49464                         LDKChannelDetails first_hops_conv_16_conv;
49465                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
49466                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
49467                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
49468                         first_hops_conv_16_conv.is_owned = false;
49469                         first_hops_constr.data[q] = first_hops_conv_16_conv;
49470                 }
49471                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
49472                 first_hops_ptr = &first_hops_constr;
49473         }
49474         void* logger_ptr = untag_ptr(logger);
49475         CHECK_ACCESS(logger_ptr);
49476         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49477         if (logger_conv.free == LDKLogger_JCalls_free) {
49478                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49479                 LDKLogger_JCalls_cloned(&logger_conv);
49480         }
49481         void* scorer_ptr = untag_ptr(scorer);
49482         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
49483         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
49484         unsigned char random_seed_bytes_arr[32];
49485         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49486         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
49487         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
49488         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
49489         *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);
49490         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
49491         return tag_ptr(ret_conv, true);
49492 }
49493
49494 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) {
49495         LDKPublicKey our_node_pubkey_ref;
49496         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
49497         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
49498         LDKCVec_PublicKeyZ hops_constr;
49499         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
49500         if (hops_constr.datalen > 0)
49501                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
49502         else
49503                 hops_constr.data = NULL;
49504         for (size_t i = 0; i < hops_constr.datalen; i++) {
49505                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
49506                 LDKPublicKey hops_conv_8_ref;
49507                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
49508                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
49509                 hops_constr.data[i] = hops_conv_8_ref;
49510         }
49511         LDKRouteParameters route_params_conv;
49512         route_params_conv.inner = untag_ptr(route_params);
49513         route_params_conv.is_owned = ptr_is_owned(route_params);
49514         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
49515         route_params_conv.is_owned = false;
49516         LDKNetworkGraph network_graph_conv;
49517         network_graph_conv.inner = untag_ptr(network_graph);
49518         network_graph_conv.is_owned = ptr_is_owned(network_graph);
49519         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49520         network_graph_conv.is_owned = false;
49521         void* logger_ptr = untag_ptr(logger);
49522         CHECK_ACCESS(logger_ptr);
49523         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49524         if (logger_conv.free == LDKLogger_JCalls_free) {
49525                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49526                 LDKLogger_JCalls_cloned(&logger_conv);
49527         }
49528         unsigned char random_seed_bytes_arr[32];
49529         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49530         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
49531         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
49532         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
49533         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
49534         return tag_ptr(ret_conv, true);
49535 }
49536
49537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49538         if (!ptr_is_owned(this_ptr)) return;
49539         void* this_ptr_ptr = untag_ptr(this_ptr);
49540         CHECK_ACCESS(this_ptr_ptr);
49541         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
49542         FREE(untag_ptr(this_ptr));
49543         Score_free(this_ptr_conv);
49544 }
49545
49546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49547         if (!ptr_is_owned(this_ptr)) return;
49548         void* this_ptr_ptr = untag_ptr(this_ptr);
49549         CHECK_ACCESS(this_ptr_ptr);
49550         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
49551         FREE(untag_ptr(this_ptr));
49552         LockableScore_free(this_ptr_conv);
49553 }
49554
49555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49556         if (!ptr_is_owned(this_ptr)) return;
49557         void* this_ptr_ptr = untag_ptr(this_ptr);
49558         CHECK_ACCESS(this_ptr_ptr);
49559         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
49560         FREE(untag_ptr(this_ptr));
49561         WriteableScore_free(this_ptr_conv);
49562 }
49563
49564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49565         LDKMultiThreadedLockableScore this_obj_conv;
49566         this_obj_conv.inner = untag_ptr(this_obj);
49567         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49569         MultiThreadedLockableScore_free(this_obj_conv);
49570 }
49571
49572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49573         LDKMultiThreadedScoreLock this_obj_conv;
49574         this_obj_conv.inner = untag_ptr(this_obj);
49575         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49577         MultiThreadedScoreLock_free(this_obj_conv);
49578 }
49579
49580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
49581         LDKMultiThreadedScoreLock this_arg_conv;
49582         this_arg_conv.inner = untag_ptr(this_arg);
49583         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49585         this_arg_conv.is_owned = false;
49586         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
49587         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
49588         return tag_ptr(ret_ret, true);
49589 }
49590
49591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
49592         LDKMultiThreadedScoreLock obj_conv;
49593         obj_conv.inner = untag_ptr(obj);
49594         obj_conv.is_owned = ptr_is_owned(obj);
49595         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49596         obj_conv.is_owned = false;
49597         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
49598         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49599         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49600         CVec_u8Z_free(ret_var);
49601         return ret_arr;
49602 }
49603
49604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
49605         LDKMultiThreadedLockableScore this_arg_conv;
49606         this_arg_conv.inner = untag_ptr(this_arg);
49607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49609         this_arg_conv.is_owned = false;
49610         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
49611         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
49612         return tag_ptr(ret_ret, true);
49613 }
49614
49615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
49616         LDKMultiThreadedLockableScore obj_conv;
49617         obj_conv.inner = untag_ptr(obj);
49618         obj_conv.is_owned = ptr_is_owned(obj);
49619         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49620         obj_conv.is_owned = false;
49621         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
49622         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49623         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49624         CVec_u8Z_free(ret_var);
49625         return ret_arr;
49626 }
49627
49628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
49629         LDKMultiThreadedLockableScore this_arg_conv;
49630         this_arg_conv.inner = untag_ptr(this_arg);
49631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49633         this_arg_conv.is_owned = false;
49634         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
49635         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
49636         return tag_ptr(ret_ret, true);
49637 }
49638
49639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
49640         void* score_ptr = untag_ptr(score);
49641         CHECK_ACCESS(score_ptr);
49642         LDKScore score_conv = *(LDKScore*)(score_ptr);
49643         if (score_conv.free == LDKScore_JCalls_free) {
49644                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49645                 LDKScore_JCalls_cloned(&score_conv);
49646         }
49647         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
49648         int64_t ret_ref = 0;
49649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49651         return ret_ref;
49652 }
49653
49654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49655         LDKChannelUsage this_obj_conv;
49656         this_obj_conv.inner = untag_ptr(this_obj);
49657         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49659         ChannelUsage_free(this_obj_conv);
49660 }
49661
49662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49663         LDKChannelUsage this_ptr_conv;
49664         this_ptr_conv.inner = untag_ptr(this_ptr);
49665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49667         this_ptr_conv.is_owned = false;
49668         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
49669         return ret_conv;
49670 }
49671
49672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49673         LDKChannelUsage this_ptr_conv;
49674         this_ptr_conv.inner = untag_ptr(this_ptr);
49675         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49677         this_ptr_conv.is_owned = false;
49678         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
49679 }
49680
49681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49682         LDKChannelUsage this_ptr_conv;
49683         this_ptr_conv.inner = untag_ptr(this_ptr);
49684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49686         this_ptr_conv.is_owned = false;
49687         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
49688         return ret_conv;
49689 }
49690
49691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49692         LDKChannelUsage this_ptr_conv;
49693         this_ptr_conv.inner = untag_ptr(this_ptr);
49694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49696         this_ptr_conv.is_owned = false;
49697         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
49698 }
49699
49700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
49701         LDKChannelUsage this_ptr_conv;
49702         this_ptr_conv.inner = untag_ptr(this_ptr);
49703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49705         this_ptr_conv.is_owned = false;
49706         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49707         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
49708         int64_t ret_ref = tag_ptr(ret_copy, true);
49709         return ret_ref;
49710 }
49711
49712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49713         LDKChannelUsage this_ptr_conv;
49714         this_ptr_conv.inner = untag_ptr(this_ptr);
49715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49717         this_ptr_conv.is_owned = false;
49718         void* val_ptr = untag_ptr(val);
49719         CHECK_ACCESS(val_ptr);
49720         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
49721         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
49722         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
49723 }
49724
49725 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) {
49726         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
49727         CHECK_ACCESS(effective_capacity_arg_ptr);
49728         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
49729         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
49730         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
49731         int64_t ret_ref = 0;
49732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49734         return ret_ref;
49735 }
49736
49737 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
49738         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
49739         int64_t ret_ref = 0;
49740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49742         return ret_ref;
49743 }
49744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49745         LDKChannelUsage arg_conv;
49746         arg_conv.inner = untag_ptr(arg);
49747         arg_conv.is_owned = ptr_is_owned(arg);
49748         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49749         arg_conv.is_owned = false;
49750         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
49751         return ret_conv;
49752 }
49753
49754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49755         LDKChannelUsage orig_conv;
49756         orig_conv.inner = untag_ptr(orig);
49757         orig_conv.is_owned = ptr_is_owned(orig);
49758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49759         orig_conv.is_owned = false;
49760         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
49761         int64_t ret_ref = 0;
49762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49764         return ret_ref;
49765 }
49766
49767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49768         LDKFixedPenaltyScorer this_obj_conv;
49769         this_obj_conv.inner = untag_ptr(this_obj);
49770         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49772         FixedPenaltyScorer_free(this_obj_conv);
49773 }
49774
49775 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
49776         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
49777         int64_t ret_ref = 0;
49778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49779         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49780         return ret_ref;
49781 }
49782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49783         LDKFixedPenaltyScorer arg_conv;
49784         arg_conv.inner = untag_ptr(arg);
49785         arg_conv.is_owned = ptr_is_owned(arg);
49786         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49787         arg_conv.is_owned = false;
49788         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
49789         return ret_conv;
49790 }
49791
49792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49793         LDKFixedPenaltyScorer orig_conv;
49794         orig_conv.inner = untag_ptr(orig);
49795         orig_conv.is_owned = ptr_is_owned(orig);
49796         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49797         orig_conv.is_owned = false;
49798         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
49799         int64_t ret_ref = 0;
49800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49802         return ret_ref;
49803 }
49804
49805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
49806         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
49807         int64_t ret_ref = 0;
49808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49810         return ret_ref;
49811 }
49812
49813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
49814         LDKFixedPenaltyScorer this_arg_conv;
49815         this_arg_conv.inner = untag_ptr(this_arg);
49816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49818         this_arg_conv.is_owned = false;
49819         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
49820         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
49821         return tag_ptr(ret_ret, true);
49822 }
49823
49824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
49825         LDKFixedPenaltyScorer obj_conv;
49826         obj_conv.inner = untag_ptr(obj);
49827         obj_conv.is_owned = ptr_is_owned(obj);
49828         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49829         obj_conv.is_owned = false;
49830         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
49831         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49832         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49833         CVec_u8Z_free(ret_var);
49834         return ret_arr;
49835 }
49836
49837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
49838         LDKu8slice ser_ref;
49839         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49840         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49841         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
49842         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
49843         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49844         return tag_ptr(ret_conv, true);
49845 }
49846
49847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49848         LDKProbabilisticScorer this_obj_conv;
49849         this_obj_conv.inner = untag_ptr(this_obj);
49850         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49852         ProbabilisticScorer_free(this_obj_conv);
49853 }
49854
49855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49856         LDKProbabilisticScoringParameters this_obj_conv;
49857         this_obj_conv.inner = untag_ptr(this_obj);
49858         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49860         ProbabilisticScoringParameters_free(this_obj_conv);
49861 }
49862
49863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49864         LDKProbabilisticScoringParameters this_ptr_conv;
49865         this_ptr_conv.inner = untag_ptr(this_ptr);
49866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49868         this_ptr_conv.is_owned = false;
49869         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
49870         return ret_conv;
49871 }
49872
49873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49874         LDKProbabilisticScoringParameters this_ptr_conv;
49875         this_ptr_conv.inner = untag_ptr(this_ptr);
49876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49878         this_ptr_conv.is_owned = false;
49879         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
49880 }
49881
49882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49883         LDKProbabilisticScoringParameters this_ptr_conv;
49884         this_ptr_conv.inner = untag_ptr(this_ptr);
49885         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49887         this_ptr_conv.is_owned = false;
49888         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
49889         return ret_conv;
49890 }
49891
49892 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) {
49893         LDKProbabilisticScoringParameters this_ptr_conv;
49894         this_ptr_conv.inner = untag_ptr(this_ptr);
49895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49897         this_ptr_conv.is_owned = false;
49898         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
49899 }
49900
49901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49902         LDKProbabilisticScoringParameters this_ptr_conv;
49903         this_ptr_conv.inner = untag_ptr(this_ptr);
49904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49906         this_ptr_conv.is_owned = false;
49907         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
49908         return ret_conv;
49909 }
49910
49911 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) {
49912         LDKProbabilisticScoringParameters this_ptr_conv;
49913         this_ptr_conv.inner = untag_ptr(this_ptr);
49914         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49916         this_ptr_conv.is_owned = false;
49917         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
49918 }
49919
49920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
49921         LDKProbabilisticScoringParameters this_ptr_conv;
49922         this_ptr_conv.inner = untag_ptr(this_ptr);
49923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49925         this_ptr_conv.is_owned = false;
49926         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
49927         return ret_conv;
49928 }
49929
49930 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) {
49931         LDKProbabilisticScoringParameters this_ptr_conv;
49932         this_ptr_conv.inner = untag_ptr(this_ptr);
49933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49935         this_ptr_conv.is_owned = false;
49936         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
49937 }
49938
49939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49940         LDKProbabilisticScoringParameters this_ptr_conv;
49941         this_ptr_conv.inner = untag_ptr(this_ptr);
49942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49944         this_ptr_conv.is_owned = false;
49945         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
49946         return ret_conv;
49947 }
49948
49949 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) {
49950         LDKProbabilisticScoringParameters this_ptr_conv;
49951         this_ptr_conv.inner = untag_ptr(this_ptr);
49952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49954         this_ptr_conv.is_owned = false;
49955         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
49956 }
49957
49958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49959         LDKProbabilisticScoringParameters this_ptr_conv;
49960         this_ptr_conv.inner = untag_ptr(this_ptr);
49961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49963         this_ptr_conv.is_owned = false;
49964         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
49965         return ret_conv;
49966 }
49967
49968 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) {
49969         LDKProbabilisticScoringParameters this_ptr_conv;
49970         this_ptr_conv.inner = untag_ptr(this_ptr);
49971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49973         this_ptr_conv.is_owned = false;
49974         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
49975 }
49976
49977 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) {
49978         LDKProbabilisticScoringParameters this_ptr_conv;
49979         this_ptr_conv.inner = untag_ptr(this_ptr);
49980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49982         this_ptr_conv.is_owned = false;
49983         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
49984         return ret_conv;
49985 }
49986
49987 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) {
49988         LDKProbabilisticScoringParameters this_ptr_conv;
49989         this_ptr_conv.inner = untag_ptr(this_ptr);
49990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49992         this_ptr_conv.is_owned = false;
49993         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
49994 }
49995
49996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
49997         LDKProbabilisticScoringParameters this_ptr_conv;
49998         this_ptr_conv.inner = untag_ptr(this_ptr);
49999         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50001         this_ptr_conv.is_owned = false;
50002         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
50003         return ret_conv;
50004 }
50005
50006 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) {
50007         LDKProbabilisticScoringParameters this_ptr_conv;
50008         this_ptr_conv.inner = untag_ptr(this_ptr);
50009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50011         this_ptr_conv.is_owned = false;
50012         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
50013 }
50014
50015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50016         LDKProbabilisticScoringParameters this_ptr_conv;
50017         this_ptr_conv.inner = untag_ptr(this_ptr);
50018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50020         this_ptr_conv.is_owned = false;
50021         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
50022         return ret_conv;
50023 }
50024
50025 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) {
50026         LDKProbabilisticScoringParameters this_ptr_conv;
50027         this_ptr_conv.inner = untag_ptr(this_ptr);
50028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50030         this_ptr_conv.is_owned = false;
50031         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
50032 }
50033
50034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50035         LDKProbabilisticScoringParameters this_ptr_conv;
50036         this_ptr_conv.inner = untag_ptr(this_ptr);
50037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50039         this_ptr_conv.is_owned = false;
50040         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
50041         return ret_conv;
50042 }
50043
50044 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) {
50045         LDKProbabilisticScoringParameters this_ptr_conv;
50046         this_ptr_conv.inner = untag_ptr(this_ptr);
50047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50049         this_ptr_conv.is_owned = false;
50050         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
50051 }
50052
50053 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
50054         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
50055         int64_t ret_ref = 0;
50056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50057         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50058         return ret_ref;
50059 }
50060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50061         LDKProbabilisticScoringParameters arg_conv;
50062         arg_conv.inner = untag_ptr(arg);
50063         arg_conv.is_owned = ptr_is_owned(arg);
50064         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50065         arg_conv.is_owned = false;
50066         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
50067         return ret_conv;
50068 }
50069
50070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50071         LDKProbabilisticScoringParameters orig_conv;
50072         orig_conv.inner = untag_ptr(orig);
50073         orig_conv.is_owned = ptr_is_owned(orig);
50074         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50075         orig_conv.is_owned = false;
50076         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
50077         int64_t ret_ref = 0;
50078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50080         return ret_ref;
50081 }
50082
50083 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) {
50084         LDKProbabilisticScoringParameters params_conv;
50085         params_conv.inner = untag_ptr(params);
50086         params_conv.is_owned = ptr_is_owned(params);
50087         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
50088         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
50089         LDKNetworkGraph network_graph_conv;
50090         network_graph_conv.inner = untag_ptr(network_graph);
50091         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50092         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50093         network_graph_conv.is_owned = false;
50094         void* logger_ptr = untag_ptr(logger);
50095         CHECK_ACCESS(logger_ptr);
50096         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50097         if (logger_conv.free == LDKLogger_JCalls_free) {
50098                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50099                 LDKLogger_JCalls_cloned(&logger_conv);
50100         }
50101         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
50102         int64_t ret_ref = 0;
50103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50104         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50105         return ret_ref;
50106 }
50107
50108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
50109         LDKProbabilisticScorer this_arg_conv;
50110         this_arg_conv.inner = untag_ptr(this_arg);
50111         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50113         this_arg_conv.is_owned = false;
50114         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
50115 }
50116
50117 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) {
50118         LDKProbabilisticScorer this_arg_conv;
50119         this_arg_conv.inner = untag_ptr(this_arg);
50120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50122         this_arg_conv.is_owned = false;
50123         LDKNodeId target_conv;
50124         target_conv.inner = untag_ptr(target);
50125         target_conv.is_owned = ptr_is_owned(target);
50126         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
50127         target_conv.is_owned = false;
50128         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
50129         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
50130         int64_t ret_ref = tag_ptr(ret_copy, true);
50131         return ret_ref;
50132 }
50133
50134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50135         LDKProbabilisticScorer this_arg_conv;
50136         this_arg_conv.inner = untag_ptr(this_arg);
50137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50139         this_arg_conv.is_owned = false;
50140         LDKNodeId node_id_conv;
50141         node_id_conv.inner = untag_ptr(node_id);
50142         node_id_conv.is_owned = ptr_is_owned(node_id);
50143         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50144         node_id_conv.is_owned = false;
50145         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
50146 }
50147
50148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50149         LDKProbabilisticScorer this_arg_conv;
50150         this_arg_conv.inner = untag_ptr(this_arg);
50151         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50153         this_arg_conv.is_owned = false;
50154         LDKNodeId node_id_conv;
50155         node_id_conv.inner = untag_ptr(node_id);
50156         node_id_conv.is_owned = ptr_is_owned(node_id);
50157         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50158         node_id_conv.is_owned = false;
50159         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
50160 }
50161
50162 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) {
50163         LDKProbabilisticScorer this_arg_conv;
50164         this_arg_conv.inner = untag_ptr(this_arg);
50165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50167         this_arg_conv.is_owned = false;
50168         LDKNodeId node_id_conv;
50169         node_id_conv.inner = untag_ptr(node_id);
50170         node_id_conv.is_owned = ptr_is_owned(node_id);
50171         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50172         node_id_conv.is_owned = false;
50173         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
50174 }
50175
50176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50177         LDKProbabilisticScorer this_arg_conv;
50178         this_arg_conv.inner = untag_ptr(this_arg);
50179         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50181         this_arg_conv.is_owned = false;
50182         LDKNodeId node_id_conv;
50183         node_id_conv.inner = untag_ptr(node_id);
50184         node_id_conv.is_owned = ptr_is_owned(node_id);
50185         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50186         node_id_conv.is_owned = false;
50187         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
50188 }
50189
50190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
50191         LDKProbabilisticScorer this_arg_conv;
50192         this_arg_conv.inner = untag_ptr(this_arg);
50193         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50195         this_arg_conv.is_owned = false;
50196         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
50197 }
50198
50199 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) {
50200         LDKProbabilisticScoringParameters this_arg_conv;
50201         this_arg_conv.inner = untag_ptr(this_arg);
50202         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50204         this_arg_conv.is_owned = false;
50205         LDKCVec_NodeIdZ node_ids_constr;
50206         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
50207         if (node_ids_constr.datalen > 0)
50208                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
50209         else
50210                 node_ids_constr.data = NULL;
50211         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
50212         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
50213                 int64_t node_ids_conv_8 = node_ids_vals[i];
50214                 LDKNodeId node_ids_conv_8_conv;
50215                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
50216                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
50217                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
50218                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
50219                 node_ids_constr.data[i] = node_ids_conv_8_conv;
50220         }
50221         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
50222         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
50223 }
50224
50225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
50226         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
50227         int64_t ret_ref = 0;
50228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50229         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50230         return ret_ref;
50231 }
50232
50233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
50234         LDKProbabilisticScorer this_arg_conv;
50235         this_arg_conv.inner = untag_ptr(this_arg);
50236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50238         this_arg_conv.is_owned = false;
50239         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
50240         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
50241         return tag_ptr(ret_ret, true);
50242 }
50243
50244 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
50245         LDKProbabilisticScorer obj_conv;
50246         obj_conv.inner = untag_ptr(obj);
50247         obj_conv.is_owned = ptr_is_owned(obj);
50248         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50249         obj_conv.is_owned = false;
50250         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
50251         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50252         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50253         CVec_u8Z_free(ret_var);
50254         return ret_arr;
50255 }
50256
50257 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) {
50258         LDKu8slice ser_ref;
50259         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50260         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50261         LDKProbabilisticScoringParameters arg_a_conv;
50262         arg_a_conv.inner = untag_ptr(arg_a);
50263         arg_a_conv.is_owned = ptr_is_owned(arg_a);
50264         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
50265         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
50266         LDKNetworkGraph arg_b_conv;
50267         arg_b_conv.inner = untag_ptr(arg_b);
50268         arg_b_conv.is_owned = ptr_is_owned(arg_b);
50269         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
50270         arg_b_conv.is_owned = false;
50271         void* arg_c_ptr = untag_ptr(arg_c);
50272         CHECK_ACCESS(arg_c_ptr);
50273         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
50274         if (arg_c_conv.free == LDKLogger_JCalls_free) {
50275                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50276                 LDKLogger_JCalls_cloned(&arg_c_conv);
50277         }
50278         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
50279         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
50280         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50281         return tag_ptr(ret_conv, true);
50282 }
50283
50284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPath_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50285         LDKBlindedPath this_obj_conv;
50286         this_obj_conv.inner = untag_ptr(this_obj);
50287         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50289         BlindedPath_free(this_obj_conv);
50290 }
50291
50292 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
50293         LDKBlindedPath ret_var = BlindedPath_clone(arg);
50294         int64_t ret_ref = 0;
50295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50297         return ret_ref;
50298 }
50299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50300         LDKBlindedPath arg_conv;
50301         arg_conv.inner = untag_ptr(arg);
50302         arg_conv.is_owned = ptr_is_owned(arg);
50303         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50304         arg_conv.is_owned = false;
50305         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
50306         return ret_conv;
50307 }
50308
50309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50310         LDKBlindedPath orig_conv;
50311         orig_conv.inner = untag_ptr(orig);
50312         orig_conv.is_owned = ptr_is_owned(orig);
50313         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50314         orig_conv.is_owned = false;
50315         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
50316         int64_t ret_ref = 0;
50317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50318         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50319         return ret_ref;
50320 }
50321
50322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50323         LDKBlindedHop this_obj_conv;
50324         this_obj_conv.inner = untag_ptr(this_obj);
50325         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50327         BlindedHop_free(this_obj_conv);
50328 }
50329
50330 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
50331         LDKBlindedHop ret_var = BlindedHop_clone(arg);
50332         int64_t ret_ref = 0;
50333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50334         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50335         return ret_ref;
50336 }
50337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50338         LDKBlindedHop arg_conv;
50339         arg_conv.inner = untag_ptr(arg);
50340         arg_conv.is_owned = ptr_is_owned(arg);
50341         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50342         arg_conv.is_owned = false;
50343         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
50344         return ret_conv;
50345 }
50346
50347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50348         LDKBlindedHop orig_conv;
50349         orig_conv.inner = untag_ptr(orig);
50350         orig_conv.is_owned = ptr_is_owned(orig);
50351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50352         orig_conv.is_owned = false;
50353         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
50354         int64_t ret_ref = 0;
50355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50356         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50357         return ret_ref;
50358 }
50359
50360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1new(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t keys_manager) {
50361         LDKCVec_PublicKeyZ node_pks_constr;
50362         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
50363         if (node_pks_constr.datalen > 0)
50364                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
50365         else
50366                 node_pks_constr.data = NULL;
50367         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
50368                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
50369                 LDKPublicKey node_pks_conv_8_ref;
50370                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
50371                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
50372                 node_pks_constr.data[i] = node_pks_conv_8_ref;
50373         }
50374         void* keys_manager_ptr = untag_ptr(keys_manager);
50375         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
50376         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
50377         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
50378         *ret_conv = BlindedPath_new(node_pks_constr, keys_manager_conv);
50379         return tag_ptr(ret_conv, true);
50380 }
50381
50382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPath_1write(JNIEnv *env, jclass clz, int64_t obj) {
50383         LDKBlindedPath obj_conv;
50384         obj_conv.inner = untag_ptr(obj);
50385         obj_conv.is_owned = ptr_is_owned(obj);
50386         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50387         obj_conv.is_owned = false;
50388         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
50389         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50390         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50391         CVec_u8Z_free(ret_var);
50392         return ret_arr;
50393 }
50394
50395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50396         LDKu8slice ser_ref;
50397         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50398         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50399         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
50400         *ret_conv = BlindedPath_read(ser_ref);
50401         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50402         return tag_ptr(ret_conv, true);
50403 }
50404
50405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
50406         LDKBlindedHop obj_conv;
50407         obj_conv.inner = untag_ptr(obj);
50408         obj_conv.is_owned = ptr_is_owned(obj);
50409         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50410         obj_conv.is_owned = false;
50411         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
50412         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50413         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50414         CVec_u8Z_free(ret_var);
50415         return ret_arr;
50416 }
50417
50418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50419         LDKu8slice ser_ref;
50420         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50421         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50422         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
50423         *ret_conv = BlindedHop_read(ser_ref);
50424         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50425         return tag_ptr(ret_conv, true);
50426 }
50427
50428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50429         LDKOnionMessenger this_obj_conv;
50430         this_obj_conv.inner = untag_ptr(this_obj);
50431         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50433         OnionMessenger_free(this_obj_conv);
50434 }
50435
50436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50437         if (!ptr_is_owned(this_ptr)) return;
50438         void* this_ptr_ptr = untag_ptr(this_ptr);
50439         CHECK_ACCESS(this_ptr_ptr);
50440         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
50441         FREE(untag_ptr(this_ptr));
50442         Destination_free(this_ptr_conv);
50443 }
50444
50445 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
50446         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50447         *ret_copy = Destination_clone(arg);
50448         int64_t ret_ref = tag_ptr(ret_copy, true);
50449         return ret_ref;
50450 }
50451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50452         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
50453         int64_t ret_conv = Destination_clone_ptr(arg_conv);
50454         return ret_conv;
50455 }
50456
50457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50458         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
50459         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50460         *ret_copy = Destination_clone(orig_conv);
50461         int64_t ret_ref = tag_ptr(ret_copy, true);
50462         return ret_ref;
50463 }
50464
50465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
50466         LDKPublicKey a_ref;
50467         CHECK((*env)->GetArrayLength(env, a) == 33);
50468         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
50469         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50470         *ret_copy = Destination_node(a_ref);
50471         int64_t ret_ref = tag_ptr(ret_copy, true);
50472         return ret_ref;
50473 }
50474
50475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1path(JNIEnv *env, jclass clz, int64_t a) {
50476         LDKBlindedPath a_conv;
50477         a_conv.inner = untag_ptr(a);
50478         a_conv.is_owned = ptr_is_owned(a);
50479         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50480         a_conv = BlindedPath_clone(&a_conv);
50481         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50482         *ret_copy = Destination_blinded_path(a_conv);
50483         int64_t ret_ref = tag_ptr(ret_copy, true);
50484         return ret_ref;
50485 }
50486
50487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50488         if (!ptr_is_owned(this_ptr)) return;
50489         void* this_ptr_ptr = untag_ptr(this_ptr);
50490         CHECK_ACCESS(this_ptr_ptr);
50491         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
50492         FREE(untag_ptr(this_ptr));
50493         SendError_free(this_ptr_conv);
50494 }
50495
50496 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
50497         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50498         *ret_copy = SendError_clone(arg);
50499         int64_t ret_ref = tag_ptr(ret_copy, true);
50500         return ret_ref;
50501 }
50502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50503         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
50504         int64_t ret_conv = SendError_clone_ptr(arg_conv);
50505         return ret_conv;
50506 }
50507
50508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50509         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
50510         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50511         *ret_copy = SendError_clone(orig_conv);
50512         int64_t ret_ref = tag_ptr(ret_copy, true);
50513         return ret_ref;
50514 }
50515
50516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
50517         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
50518         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50519         *ret_copy = SendError_secp256k1(a_conv);
50520         int64_t ret_ref = tag_ptr(ret_copy, true);
50521         return ret_ref;
50522 }
50523
50524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
50525         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50526         *ret_copy = SendError_too_big_packet();
50527         int64_t ret_ref = tag_ptr(ret_copy, true);
50528         return ret_ref;
50529 }
50530
50531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
50532         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50533         *ret_copy = SendError_too_few_blinded_hops();
50534         int64_t ret_ref = tag_ptr(ret_copy, true);
50535         return ret_ref;
50536 }
50537
50538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
50539         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50540         *ret_copy = SendError_invalid_first_hop();
50541         int64_t ret_ref = tag_ptr(ret_copy, true);
50542         return ret_ref;
50543 }
50544
50545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
50546         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50547         *ret_copy = SendError_invalid_message();
50548         int64_t ret_ref = tag_ptr(ret_copy, true);
50549         return ret_ref;
50550 }
50551
50552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
50553         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50554         *ret_copy = SendError_buffer_full();
50555         int64_t ret_ref = tag_ptr(ret_copy, true);
50556         return ret_ref;
50557 }
50558
50559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1get_1node_1id_1failed(JNIEnv *env, jclass clz) {
50560         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50561         *ret_copy = SendError_get_node_id_failed();
50562         int64_t ret_ref = tag_ptr(ret_copy, true);
50563         return ret_ref;
50564 }
50565
50566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1blinded_1path_1advance_1failed(JNIEnv *env, jclass clz) {
50567         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50568         *ret_copy = SendError_blinded_path_advance_failed();
50569         int64_t ret_ref = tag_ptr(ret_copy, true);
50570         return ret_ref;
50571 }
50572
50573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50574         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
50575         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
50576         jboolean ret_conv = SendError_eq(a_conv, b_conv);
50577         return ret_conv;
50578 }
50579
50580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50581         if (!ptr_is_owned(this_ptr)) return;
50582         void* this_ptr_ptr = untag_ptr(this_ptr);
50583         CHECK_ACCESS(this_ptr_ptr);
50584         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
50585         FREE(untag_ptr(this_ptr));
50586         CustomOnionMessageHandler_free(this_ptr_conv);
50587 }
50588
50589 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) {
50590         void* keys_manager_ptr = untag_ptr(keys_manager);
50591         CHECK_ACCESS(keys_manager_ptr);
50592         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50593         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50594                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50595                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50596         }
50597         void* logger_ptr = untag_ptr(logger);
50598         CHECK_ACCESS(logger_ptr);
50599         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50600         if (logger_conv.free == LDKLogger_JCalls_free) {
50601                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50602                 LDKLogger_JCalls_cloned(&logger_conv);
50603         }
50604         void* custom_handler_ptr = untag_ptr(custom_handler);
50605         CHECK_ACCESS(custom_handler_ptr);
50606         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
50607         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
50608                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50609                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
50610         }
50611         LDKOnionMessenger ret_var = OnionMessenger_new(keys_manager_conv, logger_conv, custom_handler_conv);
50612         int64_t ret_ref = 0;
50613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50614         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50615         return ret_ref;
50616 }
50617
50618 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) {
50619         LDKOnionMessenger this_arg_conv;
50620         this_arg_conv.inner = untag_ptr(this_arg);
50621         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50623         this_arg_conv.is_owned = false;
50624         LDKCVec_PublicKeyZ intermediate_nodes_constr;
50625         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
50626         if (intermediate_nodes_constr.datalen > 0)
50627                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
50628         else
50629                 intermediate_nodes_constr.data = NULL;
50630         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
50631                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
50632                 LDKPublicKey intermediate_nodes_conv_8_ref;
50633                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
50634                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
50635                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
50636         }
50637         void* destination_ptr = untag_ptr(destination);
50638         CHECK_ACCESS(destination_ptr);
50639         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
50640         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
50641         void* message_ptr = untag_ptr(message);
50642         CHECK_ACCESS(message_ptr);
50643         LDKOnionMessageContents message_conv = *(LDKOnionMessageContents*)(message_ptr);
50644         message_conv = OnionMessageContents_clone((LDKOnionMessageContents*)untag_ptr(message));
50645         LDKBlindedPath reply_path_conv;
50646         reply_path_conv.inner = untag_ptr(reply_path);
50647         reply_path_conv.is_owned = ptr_is_owned(reply_path);
50648         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
50649         reply_path_conv = BlindedPath_clone(&reply_path_conv);
50650         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
50651         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, message_conv, reply_path_conv);
50652         return tag_ptr(ret_conv, true);
50653 }
50654
50655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
50656         LDKOnionMessenger this_arg_conv;
50657         this_arg_conv.inner = untag_ptr(this_arg);
50658         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50660         this_arg_conv.is_owned = false;
50661         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
50662         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
50663         return tag_ptr(ret_ret, true);
50664 }
50665
50666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
50667         LDKOnionMessenger this_arg_conv;
50668         this_arg_conv.inner = untag_ptr(this_arg);
50669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50671         this_arg_conv.is_owned = false;
50672         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
50673         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
50674         return tag_ptr(ret_ret, true);
50675 }
50676
50677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50678         if (!ptr_is_owned(this_ptr)) return;
50679         void* this_ptr_ptr = untag_ptr(this_ptr);
50680         CHECK_ACCESS(this_ptr_ptr);
50681         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
50682         FREE(untag_ptr(this_ptr));
50683         OnionMessageContents_free(this_ptr_conv);
50684 }
50685
50686 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
50687         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
50688         *ret_copy = OnionMessageContents_clone(arg);
50689         int64_t ret_ref = tag_ptr(ret_copy, true);
50690         return ret_ref;
50691 }
50692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50693         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)untag_ptr(arg);
50694         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
50695         return ret_conv;
50696 }
50697
50698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50699         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)untag_ptr(orig);
50700         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
50701         *ret_copy = OnionMessageContents_clone(orig_conv);
50702         int64_t ret_ref = tag_ptr(ret_copy, true);
50703         return ret_ref;
50704 }
50705
50706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1custom(JNIEnv *env, jclass clz, int64_t a) {
50707         void* a_ptr = untag_ptr(a);
50708         CHECK_ACCESS(a_ptr);
50709         LDKCustomOnionMessageContents a_conv = *(LDKCustomOnionMessageContents*)(a_ptr);
50710         if (a_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
50711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50712                 LDKCustomOnionMessageContents_JCalls_cloned(&a_conv);
50713         }
50714         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
50715         *ret_copy = OnionMessageContents_custom(a_conv);
50716         int64_t ret_ref = tag_ptr(ret_copy, true);
50717         return ret_ref;
50718 }
50719
50720 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
50721         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
50722         *ret_ret = CustomOnionMessageContents_clone(arg);
50723         return tag_ptr(ret_ret, true);
50724 }
50725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50726         void* arg_ptr = untag_ptr(arg);
50727         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
50728         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
50729         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
50730         return ret_conv;
50731 }
50732
50733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50734         void* orig_ptr = untag_ptr(orig);
50735         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
50736         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
50737         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
50738         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
50739         return tag_ptr(ret_ret, true);
50740 }
50741
50742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50743         if (!ptr_is_owned(this_ptr)) return;
50744         void* this_ptr_ptr = untag_ptr(this_ptr);
50745         CHECK_ACCESS(this_ptr_ptr);
50746         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
50747         FREE(untag_ptr(this_ptr));
50748         CustomOnionMessageContents_free(this_ptr_conv);
50749 }
50750
50751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50752         LDKFilesystemPersister this_obj_conv;
50753         this_obj_conv.inner = untag_ptr(this_obj);
50754         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50756         FilesystemPersister_free(this_obj_conv);
50757 }
50758
50759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
50760         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
50761         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
50762         int64_t ret_ref = 0;
50763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50765         return ret_ref;
50766 }
50767
50768 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
50769         LDKFilesystemPersister this_arg_conv;
50770         this_arg_conv.inner = untag_ptr(this_arg);
50771         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50773         this_arg_conv.is_owned = false;
50774         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
50775         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50776         Str_free(ret_str);
50777         return ret_conv;
50778 }
50779
50780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
50781         LDKFilesystemPersister this_arg_conv;
50782         this_arg_conv.inner = untag_ptr(this_arg);
50783         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50785         this_arg_conv.is_owned = false;
50786         void* keys_manager_ptr = untag_ptr(keys_manager);
50787         CHECK_ACCESS(keys_manager_ptr);
50788         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50789         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50790                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50791                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50792         }
50793         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
50794         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
50795         return tag_ptr(ret_conv, true);
50796 }
50797
50798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50799         LDKBackgroundProcessor this_obj_conv;
50800         this_obj_conv.inner = untag_ptr(this_obj);
50801         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50803         BackgroundProcessor_free(this_obj_conv);
50804 }
50805
50806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50807         if (!ptr_is_owned(this_ptr)) return;
50808         void* this_ptr_ptr = untag_ptr(this_ptr);
50809         CHECK_ACCESS(this_ptr_ptr);
50810         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
50811         FREE(untag_ptr(this_ptr));
50812         GossipSync_free(this_ptr_conv);
50813 }
50814
50815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
50816         LDKP2PGossipSync a_conv;
50817         a_conv.inner = untag_ptr(a);
50818         a_conv.is_owned = ptr_is_owned(a);
50819         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50820         a_conv.is_owned = false;
50821         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
50822         *ret_copy = GossipSync_p2_p(&a_conv);
50823         int64_t ret_ref = tag_ptr(ret_copy, true);
50824         return ret_ref;
50825 }
50826
50827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
50828         LDKRapidGossipSync a_conv;
50829         a_conv.inner = untag_ptr(a);
50830         a_conv.is_owned = ptr_is_owned(a);
50831         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50832         a_conv.is_owned = false;
50833         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
50834         *ret_copy = GossipSync_rapid(&a_conv);
50835         int64_t ret_ref = tag_ptr(ret_copy, true);
50836         return ret_ref;
50837 }
50838
50839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
50840         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
50841         *ret_copy = GossipSync_none();
50842         int64_t ret_ref = tag_ptr(ret_copy, true);
50843         return ret_ref;
50844 }
50845
50846 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) {
50847         void* persister_ptr = untag_ptr(persister);
50848         CHECK_ACCESS(persister_ptr);
50849         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
50850         if (persister_conv.free == LDKPersister_JCalls_free) {
50851                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50852                 LDKPersister_JCalls_cloned(&persister_conv);
50853         }
50854         void* event_handler_ptr = untag_ptr(event_handler);
50855         CHECK_ACCESS(event_handler_ptr);
50856         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
50857         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
50858                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50859                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
50860         }
50861         LDKChainMonitor chain_monitor_conv;
50862         chain_monitor_conv.inner = untag_ptr(chain_monitor);
50863         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
50864         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
50865         chain_monitor_conv.is_owned = false;
50866         LDKChannelManager channel_manager_conv;
50867         channel_manager_conv.inner = untag_ptr(channel_manager);
50868         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
50869         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
50870         channel_manager_conv.is_owned = false;
50871         void* gossip_sync_ptr = untag_ptr(gossip_sync);
50872         CHECK_ACCESS(gossip_sync_ptr);
50873         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
50874         // WARNING: we may need a move here but no clone is available for LDKGossipSync
50875         LDKPeerManager peer_manager_conv;
50876         peer_manager_conv.inner = untag_ptr(peer_manager);
50877         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
50878         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
50879         peer_manager_conv.is_owned = false;
50880         void* logger_ptr = untag_ptr(logger);
50881         CHECK_ACCESS(logger_ptr);
50882         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50883         if (logger_conv.free == LDKLogger_JCalls_free) {
50884                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50885                 LDKLogger_JCalls_cloned(&logger_conv);
50886         }
50887         void* scorer_ptr = untag_ptr(scorer);
50888         CHECK_ACCESS(scorer_ptr);
50889         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
50890         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
50891         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
50892                 // Manually implement clone for Java trait instances
50893                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
50894                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50895                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
50896                 }
50897         }
50898         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);
50899         int64_t ret_ref = 0;
50900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50902         return ret_ref;
50903 }
50904
50905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
50906         LDKBackgroundProcessor this_arg_conv;
50907         this_arg_conv.inner = untag_ptr(this_arg);
50908         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50910         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
50911         
50912         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
50913         *ret_conv = BackgroundProcessor_join(this_arg_conv);
50914         return tag_ptr(ret_conv, true);
50915 }
50916
50917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
50918         LDKBackgroundProcessor this_arg_conv;
50919         this_arg_conv.inner = untag_ptr(this_arg);
50920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50922         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
50923         
50924         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
50925         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
50926         return tag_ptr(ret_conv, true);
50927 }
50928
50929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50930         if (!ptr_is_owned(this_ptr)) return;
50931         void* this_ptr_ptr = untag_ptr(this_ptr);
50932         CHECK_ACCESS(this_ptr_ptr);
50933         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
50934         FREE(untag_ptr(this_ptr));
50935         ParseError_free(this_ptr_conv);
50936 }
50937
50938 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
50939         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50940         *ret_copy = ParseError_clone(arg);
50941         int64_t ret_ref = tag_ptr(ret_copy, true);
50942         return ret_ref;
50943 }
50944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50945         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
50946         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
50947         return ret_conv;
50948 }
50949
50950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50951         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
50952         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50953         *ret_copy = ParseError_clone(orig_conv);
50954         int64_t ret_ref = tag_ptr(ret_copy, true);
50955         return ret_ref;
50956 }
50957
50958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
50959         void* a_ptr = untag_ptr(a);
50960         CHECK_ACCESS(a_ptr);
50961         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
50962         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
50963         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50964         *ret_copy = ParseError_bech32_error(a_conv);
50965         int64_t ret_ref = tag_ptr(ret_copy, true);
50966         return ret_ref;
50967 }
50968
50969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
50970         
50971         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50972         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
50973         int64_t ret_ref = tag_ptr(ret_copy, true);
50974         return ret_ref;
50975 }
50976
50977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
50978         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
50979         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50980         *ret_copy = ParseError_malformed_signature(a_conv);
50981         int64_t ret_ref = tag_ptr(ret_copy, true);
50982         return ret_ref;
50983 }
50984
50985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
50986         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50987         *ret_copy = ParseError_bad_prefix();
50988         int64_t ret_ref = tag_ptr(ret_copy, true);
50989         return ret_ref;
50990 }
50991
50992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
50993         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50994         *ret_copy = ParseError_unknown_currency();
50995         int64_t ret_ref = tag_ptr(ret_copy, true);
50996         return ret_ref;
50997 }
50998
50999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
51000         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51001         *ret_copy = ParseError_unknown_si_prefix();
51002         int64_t ret_ref = tag_ptr(ret_copy, true);
51003         return ret_ref;
51004 }
51005
51006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
51007         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51008         *ret_copy = ParseError_malformed_hrp();
51009         int64_t ret_ref = tag_ptr(ret_copy, true);
51010         return ret_ref;
51011 }
51012
51013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
51014         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51015         *ret_copy = ParseError_too_short_data_part();
51016         int64_t ret_ref = tag_ptr(ret_copy, true);
51017         return ret_ref;
51018 }
51019
51020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
51021         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51022         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
51023         int64_t ret_ref = tag_ptr(ret_copy, true);
51024         return ret_ref;
51025 }
51026
51027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
51028         
51029         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51030         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
51031         int64_t ret_ref = tag_ptr(ret_copy, true);
51032         return ret_ref;
51033 }
51034
51035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
51036         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51037         *ret_copy = ParseError_padding_error();
51038         int64_t ret_ref = tag_ptr(ret_copy, true);
51039         return ret_ref;
51040 }
51041
51042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
51043         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51044         *ret_copy = ParseError_integer_overflow_error();
51045         int64_t ret_ref = tag_ptr(ret_copy, true);
51046         return ret_ref;
51047 }
51048
51049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
51050         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51051         *ret_copy = ParseError_invalid_seg_wit_program_length();
51052         int64_t ret_ref = tag_ptr(ret_copy, true);
51053         return ret_ref;
51054 }
51055
51056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
51057         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51058         *ret_copy = ParseError_invalid_pub_key_hash_length();
51059         int64_t ret_ref = tag_ptr(ret_copy, true);
51060         return ret_ref;
51061 }
51062
51063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
51064         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51065         *ret_copy = ParseError_invalid_script_hash_length();
51066         int64_t ret_ref = tag_ptr(ret_copy, true);
51067         return ret_ref;
51068 }
51069
51070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
51071         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51072         *ret_copy = ParseError_invalid_recovery_id();
51073         int64_t ret_ref = tag_ptr(ret_copy, true);
51074         return ret_ref;
51075 }
51076
51077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
51078         LDKStr a_conv = java_to_owned_str(env, a);
51079         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51080         *ret_copy = ParseError_invalid_slice_length(a_conv);
51081         int64_t ret_ref = tag_ptr(ret_copy, true);
51082         return ret_ref;
51083 }
51084
51085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
51086         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51087         *ret_copy = ParseError_skip();
51088         int64_t ret_ref = tag_ptr(ret_copy, true);
51089         return ret_ref;
51090 }
51091
51092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51093         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
51094         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
51095         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
51096         return ret_conv;
51097 }
51098
51099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51100         if (!ptr_is_owned(this_ptr)) return;
51101         void* this_ptr_ptr = untag_ptr(this_ptr);
51102         CHECK_ACCESS(this_ptr_ptr);
51103         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
51104         FREE(untag_ptr(this_ptr));
51105         ParseOrSemanticError_free(this_ptr_conv);
51106 }
51107
51108 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
51109         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51110         *ret_copy = ParseOrSemanticError_clone(arg);
51111         int64_t ret_ref = tag_ptr(ret_copy, true);
51112         return ret_ref;
51113 }
51114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51115         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
51116         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
51117         return ret_conv;
51118 }
51119
51120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51121         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
51122         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51123         *ret_copy = ParseOrSemanticError_clone(orig_conv);
51124         int64_t ret_ref = tag_ptr(ret_copy, true);
51125         return ret_ref;
51126 }
51127
51128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
51129         void* a_ptr = untag_ptr(a);
51130         CHECK_ACCESS(a_ptr);
51131         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
51132         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
51133         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51134         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
51135         int64_t ret_ref = tag_ptr(ret_copy, true);
51136         return ret_ref;
51137 }
51138
51139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
51140         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
51141         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51142         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
51143         int64_t ret_ref = tag_ptr(ret_copy, true);
51144         return ret_ref;
51145 }
51146
51147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51148         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
51149         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
51150         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
51151         return ret_conv;
51152 }
51153
51154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51155         LDKInvoice this_obj_conv;
51156         this_obj_conv.inner = untag_ptr(this_obj);
51157         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51159         Invoice_free(this_obj_conv);
51160 }
51161
51162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51163         LDKInvoice a_conv;
51164         a_conv.inner = untag_ptr(a);
51165         a_conv.is_owned = ptr_is_owned(a);
51166         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51167         a_conv.is_owned = false;
51168         LDKInvoice b_conv;
51169         b_conv.inner = untag_ptr(b);
51170         b_conv.is_owned = ptr_is_owned(b);
51171         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51172         b_conv.is_owned = false;
51173         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
51174         return ret_conv;
51175 }
51176
51177 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
51178         LDKInvoice ret_var = Invoice_clone(arg);
51179         int64_t ret_ref = 0;
51180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51182         return ret_ref;
51183 }
51184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51185         LDKInvoice arg_conv;
51186         arg_conv.inner = untag_ptr(arg);
51187         arg_conv.is_owned = ptr_is_owned(arg);
51188         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51189         arg_conv.is_owned = false;
51190         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
51191         return ret_conv;
51192 }
51193
51194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51195         LDKInvoice orig_conv;
51196         orig_conv.inner = untag_ptr(orig);
51197         orig_conv.is_owned = ptr_is_owned(orig);
51198         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51199         orig_conv.is_owned = false;
51200         LDKInvoice ret_var = Invoice_clone(&orig_conv);
51201         int64_t ret_ref = 0;
51202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51204         return ret_ref;
51205 }
51206
51207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
51208         LDKInvoice o_conv;
51209         o_conv.inner = untag_ptr(o);
51210         o_conv.is_owned = ptr_is_owned(o);
51211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51212         o_conv.is_owned = false;
51213         int64_t ret_conv = Invoice_hash(&o_conv);
51214         return ret_conv;
51215 }
51216
51217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51218         LDKSignedRawInvoice this_obj_conv;
51219         this_obj_conv.inner = untag_ptr(this_obj);
51220         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51222         SignedRawInvoice_free(this_obj_conv);
51223 }
51224
51225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51226         LDKSignedRawInvoice a_conv;
51227         a_conv.inner = untag_ptr(a);
51228         a_conv.is_owned = ptr_is_owned(a);
51229         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51230         a_conv.is_owned = false;
51231         LDKSignedRawInvoice b_conv;
51232         b_conv.inner = untag_ptr(b);
51233         b_conv.is_owned = ptr_is_owned(b);
51234         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51235         b_conv.is_owned = false;
51236         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
51237         return ret_conv;
51238 }
51239
51240 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
51241         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
51242         int64_t ret_ref = 0;
51243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51245         return ret_ref;
51246 }
51247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51248         LDKSignedRawInvoice arg_conv;
51249         arg_conv.inner = untag_ptr(arg);
51250         arg_conv.is_owned = ptr_is_owned(arg);
51251         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51252         arg_conv.is_owned = false;
51253         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
51254         return ret_conv;
51255 }
51256
51257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51258         LDKSignedRawInvoice orig_conv;
51259         orig_conv.inner = untag_ptr(orig);
51260         orig_conv.is_owned = ptr_is_owned(orig);
51261         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51262         orig_conv.is_owned = false;
51263         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
51264         int64_t ret_ref = 0;
51265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51266         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51267         return ret_ref;
51268 }
51269
51270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
51271         LDKSignedRawInvoice o_conv;
51272         o_conv.inner = untag_ptr(o);
51273         o_conv.is_owned = ptr_is_owned(o);
51274         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51275         o_conv.is_owned = false;
51276         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
51277         return ret_conv;
51278 }
51279
51280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51281         LDKRawInvoice this_obj_conv;
51282         this_obj_conv.inner = untag_ptr(this_obj);
51283         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51285         RawInvoice_free(this_obj_conv);
51286 }
51287
51288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
51289         LDKRawInvoice this_ptr_conv;
51290         this_ptr_conv.inner = untag_ptr(this_ptr);
51291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51293         this_ptr_conv.is_owned = false;
51294         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
51295         int64_t ret_ref = 0;
51296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51297         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51298         return ret_ref;
51299 }
51300
51301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51302         LDKRawInvoice this_ptr_conv;
51303         this_ptr_conv.inner = untag_ptr(this_ptr);
51304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51306         this_ptr_conv.is_owned = false;
51307         LDKRawDataPart val_conv;
51308         val_conv.inner = untag_ptr(val);
51309         val_conv.is_owned = ptr_is_owned(val);
51310         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51311         val_conv = RawDataPart_clone(&val_conv);
51312         RawInvoice_set_data(&this_ptr_conv, val_conv);
51313 }
51314
51315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51316         LDKRawInvoice a_conv;
51317         a_conv.inner = untag_ptr(a);
51318         a_conv.is_owned = ptr_is_owned(a);
51319         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51320         a_conv.is_owned = false;
51321         LDKRawInvoice b_conv;
51322         b_conv.inner = untag_ptr(b);
51323         b_conv.is_owned = ptr_is_owned(b);
51324         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51325         b_conv.is_owned = false;
51326         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
51327         return ret_conv;
51328 }
51329
51330 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
51331         LDKRawInvoice ret_var = RawInvoice_clone(arg);
51332         int64_t ret_ref = 0;
51333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51334         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51335         return ret_ref;
51336 }
51337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51338         LDKRawInvoice arg_conv;
51339         arg_conv.inner = untag_ptr(arg);
51340         arg_conv.is_owned = ptr_is_owned(arg);
51341         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51342         arg_conv.is_owned = false;
51343         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
51344         return ret_conv;
51345 }
51346
51347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51348         LDKRawInvoice orig_conv;
51349         orig_conv.inner = untag_ptr(orig);
51350         orig_conv.is_owned = ptr_is_owned(orig);
51351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51352         orig_conv.is_owned = false;
51353         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
51354         int64_t ret_ref = 0;
51355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51356         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51357         return ret_ref;
51358 }
51359
51360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
51361         LDKRawInvoice o_conv;
51362         o_conv.inner = untag_ptr(o);
51363         o_conv.is_owned = ptr_is_owned(o);
51364         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51365         o_conv.is_owned = false;
51366         int64_t ret_conv = RawInvoice_hash(&o_conv);
51367         return ret_conv;
51368 }
51369
51370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51371         LDKRawDataPart this_obj_conv;
51372         this_obj_conv.inner = untag_ptr(this_obj);
51373         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51375         RawDataPart_free(this_obj_conv);
51376 }
51377
51378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
51379         LDKRawDataPart this_ptr_conv;
51380         this_ptr_conv.inner = untag_ptr(this_ptr);
51381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51383         this_ptr_conv.is_owned = false;
51384         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
51385         int64_t ret_ref = 0;
51386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51388         return ret_ref;
51389 }
51390
51391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51392         LDKRawDataPart this_ptr_conv;
51393         this_ptr_conv.inner = untag_ptr(this_ptr);
51394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51396         this_ptr_conv.is_owned = false;
51397         LDKPositiveTimestamp val_conv;
51398         val_conv.inner = untag_ptr(val);
51399         val_conv.is_owned = ptr_is_owned(val);
51400         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51401         val_conv = PositiveTimestamp_clone(&val_conv);
51402         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
51403 }
51404
51405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51406         LDKRawDataPart a_conv;
51407         a_conv.inner = untag_ptr(a);
51408         a_conv.is_owned = ptr_is_owned(a);
51409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51410         a_conv.is_owned = false;
51411         LDKRawDataPart b_conv;
51412         b_conv.inner = untag_ptr(b);
51413         b_conv.is_owned = ptr_is_owned(b);
51414         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51415         b_conv.is_owned = false;
51416         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
51417         return ret_conv;
51418 }
51419
51420 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
51421         LDKRawDataPart ret_var = RawDataPart_clone(arg);
51422         int64_t ret_ref = 0;
51423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51425         return ret_ref;
51426 }
51427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51428         LDKRawDataPart arg_conv;
51429         arg_conv.inner = untag_ptr(arg);
51430         arg_conv.is_owned = ptr_is_owned(arg);
51431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51432         arg_conv.is_owned = false;
51433         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
51434         return ret_conv;
51435 }
51436
51437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51438         LDKRawDataPart orig_conv;
51439         orig_conv.inner = untag_ptr(orig);
51440         orig_conv.is_owned = ptr_is_owned(orig);
51441         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51442         orig_conv.is_owned = false;
51443         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
51444         int64_t ret_ref = 0;
51445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51446         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51447         return ret_ref;
51448 }
51449
51450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
51451         LDKRawDataPart o_conv;
51452         o_conv.inner = untag_ptr(o);
51453         o_conv.is_owned = ptr_is_owned(o);
51454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51455         o_conv.is_owned = false;
51456         int64_t ret_conv = RawDataPart_hash(&o_conv);
51457         return ret_conv;
51458 }
51459
51460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51461         LDKPositiveTimestamp this_obj_conv;
51462         this_obj_conv.inner = untag_ptr(this_obj);
51463         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51465         PositiveTimestamp_free(this_obj_conv);
51466 }
51467
51468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51469         LDKPositiveTimestamp a_conv;
51470         a_conv.inner = untag_ptr(a);
51471         a_conv.is_owned = ptr_is_owned(a);
51472         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51473         a_conv.is_owned = false;
51474         LDKPositiveTimestamp b_conv;
51475         b_conv.inner = untag_ptr(b);
51476         b_conv.is_owned = ptr_is_owned(b);
51477         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51478         b_conv.is_owned = false;
51479         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
51480         return ret_conv;
51481 }
51482
51483 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
51484         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
51485         int64_t ret_ref = 0;
51486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51487         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51488         return ret_ref;
51489 }
51490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51491         LDKPositiveTimestamp arg_conv;
51492         arg_conv.inner = untag_ptr(arg);
51493         arg_conv.is_owned = ptr_is_owned(arg);
51494         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51495         arg_conv.is_owned = false;
51496         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
51497         return ret_conv;
51498 }
51499
51500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51501         LDKPositiveTimestamp orig_conv;
51502         orig_conv.inner = untag_ptr(orig);
51503         orig_conv.is_owned = ptr_is_owned(orig);
51504         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51505         orig_conv.is_owned = false;
51506         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
51507         int64_t ret_ref = 0;
51508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51510         return ret_ref;
51511 }
51512
51513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
51514         LDKPositiveTimestamp o_conv;
51515         o_conv.inner = untag_ptr(o);
51516         o_conv.is_owned = ptr_is_owned(o);
51517         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51518         o_conv.is_owned = false;
51519         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
51520         return ret_conv;
51521 }
51522
51523 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51524         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
51525         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
51526         return ret_conv;
51527 }
51528
51529 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
51530         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
51531         return ret_conv;
51532 }
51533
51534 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
51535         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
51536         return ret_conv;
51537 }
51538
51539 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
51540         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
51541         return ret_conv;
51542 }
51543
51544 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
51545         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
51546         return ret_conv;
51547 }
51548
51549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51550         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
51551         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
51552         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
51553         return ret_conv;
51554 }
51555
51556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
51557         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
51558         int64_t ret_conv = SiPrefix_hash(o_conv);
51559         return ret_conv;
51560 }
51561
51562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
51563         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
51564         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
51565         return ret_conv;
51566 }
51567
51568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51569         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
51570         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
51571         return ret_conv;
51572 }
51573
51574 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
51575         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
51576         return ret_conv;
51577 }
51578
51579 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
51580         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
51581         return ret_conv;
51582 }
51583
51584 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
51585         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
51586         return ret_conv;
51587 }
51588
51589 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
51590         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
51591         return ret_conv;
51592 }
51593
51594 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
51595         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
51596         return ret_conv;
51597 }
51598
51599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
51600         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
51601         int64_t ret_conv = Currency_hash(o_conv);
51602         return ret_conv;
51603 }
51604
51605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51606         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
51607         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
51608         jboolean ret_conv = Currency_eq(a_conv, b_conv);
51609         return ret_conv;
51610 }
51611
51612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51613         LDKSha256 this_obj_conv;
51614         this_obj_conv.inner = untag_ptr(this_obj);
51615         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51617         Sha256_free(this_obj_conv);
51618 }
51619
51620 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
51621         LDKSha256 ret_var = Sha256_clone(arg);
51622         int64_t ret_ref = 0;
51623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51625         return ret_ref;
51626 }
51627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51628         LDKSha256 arg_conv;
51629         arg_conv.inner = untag_ptr(arg);
51630         arg_conv.is_owned = ptr_is_owned(arg);
51631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51632         arg_conv.is_owned = false;
51633         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
51634         return ret_conv;
51635 }
51636
51637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51638         LDKSha256 orig_conv;
51639         orig_conv.inner = untag_ptr(orig);
51640         orig_conv.is_owned = ptr_is_owned(orig);
51641         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51642         orig_conv.is_owned = false;
51643         LDKSha256 ret_var = Sha256_clone(&orig_conv);
51644         int64_t ret_ref = 0;
51645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51647         return ret_ref;
51648 }
51649
51650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
51651         LDKSha256 o_conv;
51652         o_conv.inner = untag_ptr(o);
51653         o_conv.is_owned = ptr_is_owned(o);
51654         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51655         o_conv.is_owned = false;
51656         int64_t ret_conv = Sha256_hash(&o_conv);
51657         return ret_conv;
51658 }
51659
51660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51661         LDKSha256 a_conv;
51662         a_conv.inner = untag_ptr(a);
51663         a_conv.is_owned = ptr_is_owned(a);
51664         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51665         a_conv.is_owned = false;
51666         LDKSha256 b_conv;
51667         b_conv.inner = untag_ptr(b);
51668         b_conv.is_owned = ptr_is_owned(b);
51669         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51670         b_conv.is_owned = false;
51671         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
51672         return ret_conv;
51673 }
51674
51675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51676         LDKDescription this_obj_conv;
51677         this_obj_conv.inner = untag_ptr(this_obj);
51678         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51680         Description_free(this_obj_conv);
51681 }
51682
51683 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
51684         LDKDescription ret_var = Description_clone(arg);
51685         int64_t ret_ref = 0;
51686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51688         return ret_ref;
51689 }
51690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51691         LDKDescription arg_conv;
51692         arg_conv.inner = untag_ptr(arg);
51693         arg_conv.is_owned = ptr_is_owned(arg);
51694         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51695         arg_conv.is_owned = false;
51696         int64_t ret_conv = Description_clone_ptr(&arg_conv);
51697         return ret_conv;
51698 }
51699
51700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51701         LDKDescription orig_conv;
51702         orig_conv.inner = untag_ptr(orig);
51703         orig_conv.is_owned = ptr_is_owned(orig);
51704         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51705         orig_conv.is_owned = false;
51706         LDKDescription ret_var = Description_clone(&orig_conv);
51707         int64_t ret_ref = 0;
51708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51710         return ret_ref;
51711 }
51712
51713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
51714         LDKDescription o_conv;
51715         o_conv.inner = untag_ptr(o);
51716         o_conv.is_owned = ptr_is_owned(o);
51717         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51718         o_conv.is_owned = false;
51719         int64_t ret_conv = Description_hash(&o_conv);
51720         return ret_conv;
51721 }
51722
51723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51724         LDKDescription a_conv;
51725         a_conv.inner = untag_ptr(a);
51726         a_conv.is_owned = ptr_is_owned(a);
51727         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51728         a_conv.is_owned = false;
51729         LDKDescription b_conv;
51730         b_conv.inner = untag_ptr(b);
51731         b_conv.is_owned = ptr_is_owned(b);
51732         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51733         b_conv.is_owned = false;
51734         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
51735         return ret_conv;
51736 }
51737
51738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51739         LDKPayeePubKey this_obj_conv;
51740         this_obj_conv.inner = untag_ptr(this_obj);
51741         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51743         PayeePubKey_free(this_obj_conv);
51744 }
51745
51746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
51747         LDKPayeePubKey this_ptr_conv;
51748         this_ptr_conv.inner = untag_ptr(this_ptr);
51749         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51751         this_ptr_conv.is_owned = false;
51752         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
51753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
51754         return ret_arr;
51755 }
51756
51757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
51758         LDKPayeePubKey this_ptr_conv;
51759         this_ptr_conv.inner = untag_ptr(this_ptr);
51760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51762         this_ptr_conv.is_owned = false;
51763         LDKPublicKey val_ref;
51764         CHECK((*env)->GetArrayLength(env, val) == 33);
51765         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
51766         PayeePubKey_set_a(&this_ptr_conv, val_ref);
51767 }
51768
51769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
51770         LDKPublicKey a_arg_ref;
51771         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
51772         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
51773         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
51774         int64_t ret_ref = 0;
51775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51777         return ret_ref;
51778 }
51779
51780 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
51781         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
51782         int64_t ret_ref = 0;
51783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51785         return ret_ref;
51786 }
51787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51788         LDKPayeePubKey arg_conv;
51789         arg_conv.inner = untag_ptr(arg);
51790         arg_conv.is_owned = ptr_is_owned(arg);
51791         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51792         arg_conv.is_owned = false;
51793         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
51794         return ret_conv;
51795 }
51796
51797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51798         LDKPayeePubKey orig_conv;
51799         orig_conv.inner = untag_ptr(orig);
51800         orig_conv.is_owned = ptr_is_owned(orig);
51801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51802         orig_conv.is_owned = false;
51803         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
51804         int64_t ret_ref = 0;
51805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51806         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51807         return ret_ref;
51808 }
51809
51810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
51811         LDKPayeePubKey o_conv;
51812         o_conv.inner = untag_ptr(o);
51813         o_conv.is_owned = ptr_is_owned(o);
51814         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51815         o_conv.is_owned = false;
51816         int64_t ret_conv = PayeePubKey_hash(&o_conv);
51817         return ret_conv;
51818 }
51819
51820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51821         LDKPayeePubKey a_conv;
51822         a_conv.inner = untag_ptr(a);
51823         a_conv.is_owned = ptr_is_owned(a);
51824         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51825         a_conv.is_owned = false;
51826         LDKPayeePubKey b_conv;
51827         b_conv.inner = untag_ptr(b);
51828         b_conv.is_owned = ptr_is_owned(b);
51829         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51830         b_conv.is_owned = false;
51831         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
51832         return ret_conv;
51833 }
51834
51835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51836         LDKExpiryTime this_obj_conv;
51837         this_obj_conv.inner = untag_ptr(this_obj);
51838         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51840         ExpiryTime_free(this_obj_conv);
51841 }
51842
51843 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
51844         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
51845         int64_t ret_ref = 0;
51846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51848         return ret_ref;
51849 }
51850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51851         LDKExpiryTime arg_conv;
51852         arg_conv.inner = untag_ptr(arg);
51853         arg_conv.is_owned = ptr_is_owned(arg);
51854         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51855         arg_conv.is_owned = false;
51856         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
51857         return ret_conv;
51858 }
51859
51860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51861         LDKExpiryTime orig_conv;
51862         orig_conv.inner = untag_ptr(orig);
51863         orig_conv.is_owned = ptr_is_owned(orig);
51864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51865         orig_conv.is_owned = false;
51866         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
51867         int64_t ret_ref = 0;
51868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51870         return ret_ref;
51871 }
51872
51873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
51874         LDKExpiryTime o_conv;
51875         o_conv.inner = untag_ptr(o);
51876         o_conv.is_owned = ptr_is_owned(o);
51877         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51878         o_conv.is_owned = false;
51879         int64_t ret_conv = ExpiryTime_hash(&o_conv);
51880         return ret_conv;
51881 }
51882
51883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51884         LDKExpiryTime a_conv;
51885         a_conv.inner = untag_ptr(a);
51886         a_conv.is_owned = ptr_is_owned(a);
51887         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51888         a_conv.is_owned = false;
51889         LDKExpiryTime b_conv;
51890         b_conv.inner = untag_ptr(b);
51891         b_conv.is_owned = ptr_is_owned(b);
51892         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51893         b_conv.is_owned = false;
51894         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
51895         return ret_conv;
51896 }
51897
51898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51899         LDKMinFinalCltvExpiry this_obj_conv;
51900         this_obj_conv.inner = untag_ptr(this_obj);
51901         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51903         MinFinalCltvExpiry_free(this_obj_conv);
51904 }
51905
51906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
51907         LDKMinFinalCltvExpiry this_ptr_conv;
51908         this_ptr_conv.inner = untag_ptr(this_ptr);
51909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51911         this_ptr_conv.is_owned = false;
51912         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
51913         return ret_conv;
51914 }
51915
51916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51917         LDKMinFinalCltvExpiry this_ptr_conv;
51918         this_ptr_conv.inner = untag_ptr(this_ptr);
51919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51921         this_ptr_conv.is_owned = false;
51922         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
51923 }
51924
51925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
51926         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
51927         int64_t ret_ref = 0;
51928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51930         return ret_ref;
51931 }
51932
51933 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
51934         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
51935         int64_t ret_ref = 0;
51936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51938         return ret_ref;
51939 }
51940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51941         LDKMinFinalCltvExpiry arg_conv;
51942         arg_conv.inner = untag_ptr(arg);
51943         arg_conv.is_owned = ptr_is_owned(arg);
51944         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51945         arg_conv.is_owned = false;
51946         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
51947         return ret_conv;
51948 }
51949
51950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51951         LDKMinFinalCltvExpiry orig_conv;
51952         orig_conv.inner = untag_ptr(orig);
51953         orig_conv.is_owned = ptr_is_owned(orig);
51954         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51955         orig_conv.is_owned = false;
51956         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
51957         int64_t ret_ref = 0;
51958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51960         return ret_ref;
51961 }
51962
51963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
51964         LDKMinFinalCltvExpiry o_conv;
51965         o_conv.inner = untag_ptr(o);
51966         o_conv.is_owned = ptr_is_owned(o);
51967         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51968         o_conv.is_owned = false;
51969         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
51970         return ret_conv;
51971 }
51972
51973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51974         LDKMinFinalCltvExpiry a_conv;
51975         a_conv.inner = untag_ptr(a);
51976         a_conv.is_owned = ptr_is_owned(a);
51977         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51978         a_conv.is_owned = false;
51979         LDKMinFinalCltvExpiry b_conv;
51980         b_conv.inner = untag_ptr(b);
51981         b_conv.is_owned = ptr_is_owned(b);
51982         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51983         b_conv.is_owned = false;
51984         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
51985         return ret_conv;
51986 }
51987
51988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51989         if (!ptr_is_owned(this_ptr)) return;
51990         void* this_ptr_ptr = untag_ptr(this_ptr);
51991         CHECK_ACCESS(this_ptr_ptr);
51992         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
51993         FREE(untag_ptr(this_ptr));
51994         Fallback_free(this_ptr_conv);
51995 }
51996
51997 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
51998         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
51999         *ret_copy = Fallback_clone(arg);
52000         int64_t ret_ref = tag_ptr(ret_copy, true);
52001         return ret_ref;
52002 }
52003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52004         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
52005         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
52006         return ret_conv;
52007 }
52008
52009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52010         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
52011         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52012         *ret_copy = Fallback_clone(orig_conv);
52013         int64_t ret_ref = tag_ptr(ret_copy, true);
52014         return ret_ref;
52015 }
52016
52017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
52018         
52019         LDKCVec_u8Z program_ref;
52020         program_ref.datalen = (*env)->GetArrayLength(env, program);
52021         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
52022         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
52023         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52024         *ret_copy = Fallback_seg_wit_program((LDKU5){ ._0 = version }, program_ref);
52025         int64_t ret_ref = tag_ptr(ret_copy, true);
52026         return ret_ref;
52027 }
52028
52029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
52030         LDKTwentyBytes a_ref;
52031         CHECK((*env)->GetArrayLength(env, a) == 20);
52032         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
52033         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52034         *ret_copy = Fallback_pub_key_hash(a_ref);
52035         int64_t ret_ref = tag_ptr(ret_copy, true);
52036         return ret_ref;
52037 }
52038
52039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
52040         LDKTwentyBytes a_ref;
52041         CHECK((*env)->GetArrayLength(env, a) == 20);
52042         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
52043         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52044         *ret_copy = Fallback_script_hash(a_ref);
52045         int64_t ret_ref = tag_ptr(ret_copy, true);
52046         return ret_ref;
52047 }
52048
52049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
52050         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
52051         int64_t ret_conv = Fallback_hash(o_conv);
52052         return ret_conv;
52053 }
52054
52055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52056         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
52057         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
52058         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
52059         return ret_conv;
52060 }
52061
52062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52063         LDKInvoiceSignature this_obj_conv;
52064         this_obj_conv.inner = untag_ptr(this_obj);
52065         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52067         InvoiceSignature_free(this_obj_conv);
52068 }
52069
52070 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
52071         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
52072         int64_t ret_ref = 0;
52073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52074         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52075         return ret_ref;
52076 }
52077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52078         LDKInvoiceSignature arg_conv;
52079         arg_conv.inner = untag_ptr(arg);
52080         arg_conv.is_owned = ptr_is_owned(arg);
52081         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52082         arg_conv.is_owned = false;
52083         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
52084         return ret_conv;
52085 }
52086
52087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52088         LDKInvoiceSignature orig_conv;
52089         orig_conv.inner = untag_ptr(orig);
52090         orig_conv.is_owned = ptr_is_owned(orig);
52091         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52092         orig_conv.is_owned = false;
52093         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
52094         int64_t ret_ref = 0;
52095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52097         return ret_ref;
52098 }
52099
52100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
52101         LDKInvoiceSignature o_conv;
52102         o_conv.inner = untag_ptr(o);
52103         o_conv.is_owned = ptr_is_owned(o);
52104         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52105         o_conv.is_owned = false;
52106         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
52107         return ret_conv;
52108 }
52109
52110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52111         LDKInvoiceSignature a_conv;
52112         a_conv.inner = untag_ptr(a);
52113         a_conv.is_owned = ptr_is_owned(a);
52114         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52115         a_conv.is_owned = false;
52116         LDKInvoiceSignature b_conv;
52117         b_conv.inner = untag_ptr(b);
52118         b_conv.is_owned = ptr_is_owned(b);
52119         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52120         b_conv.is_owned = false;
52121         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
52122         return ret_conv;
52123 }
52124
52125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52126         LDKPrivateRoute this_obj_conv;
52127         this_obj_conv.inner = untag_ptr(this_obj);
52128         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52130         PrivateRoute_free(this_obj_conv);
52131 }
52132
52133 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
52134         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
52135         int64_t ret_ref = 0;
52136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52137         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52138         return ret_ref;
52139 }
52140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52141         LDKPrivateRoute arg_conv;
52142         arg_conv.inner = untag_ptr(arg);
52143         arg_conv.is_owned = ptr_is_owned(arg);
52144         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52145         arg_conv.is_owned = false;
52146         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
52147         return ret_conv;
52148 }
52149
52150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52151         LDKPrivateRoute orig_conv;
52152         orig_conv.inner = untag_ptr(orig);
52153         orig_conv.is_owned = ptr_is_owned(orig);
52154         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52155         orig_conv.is_owned = false;
52156         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
52157         int64_t ret_ref = 0;
52158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52160         return ret_ref;
52161 }
52162
52163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
52164         LDKPrivateRoute o_conv;
52165         o_conv.inner = untag_ptr(o);
52166         o_conv.is_owned = ptr_is_owned(o);
52167         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52168         o_conv.is_owned = false;
52169         int64_t ret_conv = PrivateRoute_hash(&o_conv);
52170         return ret_conv;
52171 }
52172
52173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52174         LDKPrivateRoute a_conv;
52175         a_conv.inner = untag_ptr(a);
52176         a_conv.is_owned = ptr_is_owned(a);
52177         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52178         a_conv.is_owned = false;
52179         LDKPrivateRoute b_conv;
52180         b_conv.inner = untag_ptr(b);
52181         b_conv.is_owned = ptr_is_owned(b);
52182         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52183         b_conv.is_owned = false;
52184         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
52185         return ret_conv;
52186 }
52187
52188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
52189         LDKSignedRawInvoice this_arg_conv;
52190         this_arg_conv.inner = untag_ptr(this_arg);
52191         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52193         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
52194         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
52195         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
52196         return tag_ptr(ret_conv, true);
52197 }
52198
52199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
52200         LDKSignedRawInvoice this_arg_conv;
52201         this_arg_conv.inner = untag_ptr(this_arg);
52202         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52204         this_arg_conv.is_owned = false;
52205         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
52206         int64_t ret_ref = 0;
52207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52209         return ret_ref;
52210 }
52211
52212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52213         LDKSignedRawInvoice this_arg_conv;
52214         this_arg_conv.inner = untag_ptr(this_arg);
52215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52217         this_arg_conv.is_owned = false;
52218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
52220         return ret_arr;
52221 }
52222
52223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
52224         LDKSignedRawInvoice this_arg_conv;
52225         this_arg_conv.inner = untag_ptr(this_arg);
52226         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52228         this_arg_conv.is_owned = false;
52229         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
52230         int64_t ret_ref = 0;
52231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52233         return ret_ref;
52234 }
52235
52236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52237         LDKSignedRawInvoice this_arg_conv;
52238         this_arg_conv.inner = untag_ptr(this_arg);
52239         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52241         this_arg_conv.is_owned = false;
52242         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
52243         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
52244         return tag_ptr(ret_conv, true);
52245 }
52246
52247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
52248         LDKSignedRawInvoice this_arg_conv;
52249         this_arg_conv.inner = untag_ptr(this_arg);
52250         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52252         this_arg_conv.is_owned = false;
52253         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
52254         return ret_conv;
52255 }
52256
52257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52258         LDKRawInvoice this_arg_conv;
52259         this_arg_conv.inner = untag_ptr(this_arg);
52260         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52262         this_arg_conv.is_owned = false;
52263         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52264         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
52265         return ret_arr;
52266 }
52267
52268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52269         LDKRawInvoice this_arg_conv;
52270         this_arg_conv.inner = untag_ptr(this_arg);
52271         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52273         this_arg_conv.is_owned = false;
52274         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
52275         int64_t ret_ref = 0;
52276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52278         return ret_ref;
52279 }
52280
52281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
52282         LDKRawInvoice this_arg_conv;
52283         this_arg_conv.inner = untag_ptr(this_arg);
52284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52286         this_arg_conv.is_owned = false;
52287         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
52288         int64_t ret_ref = 0;
52289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52291         return ret_ref;
52292 }
52293
52294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52295         LDKRawInvoice this_arg_conv;
52296         this_arg_conv.inner = untag_ptr(this_arg);
52297         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52299         this_arg_conv.is_owned = false;
52300         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
52301         int64_t ret_ref = 0;
52302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52303         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52304         return ret_ref;
52305 }
52306
52307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52308         LDKRawInvoice this_arg_conv;
52309         this_arg_conv.inner = untag_ptr(this_arg);
52310         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52312         this_arg_conv.is_owned = false;
52313         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
52314         int64_t ret_ref = 0;
52315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52317         return ret_ref;
52318 }
52319
52320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
52321         LDKRawInvoice this_arg_conv;
52322         this_arg_conv.inner = untag_ptr(this_arg);
52323         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52325         this_arg_conv.is_owned = false;
52326         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
52327         int64_t ret_ref = 0;
52328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52329         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52330         return ret_ref;
52331 }
52332
52333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
52334         LDKRawInvoice this_arg_conv;
52335         this_arg_conv.inner = untag_ptr(this_arg);
52336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52338         this_arg_conv.is_owned = false;
52339         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
52340         int64_t ret_ref = 0;
52341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52342         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52343         return ret_ref;
52344 }
52345
52346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
52347         LDKRawInvoice this_arg_conv;
52348         this_arg_conv.inner = untag_ptr(this_arg);
52349         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52351         this_arg_conv.is_owned = false;
52352         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52353         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
52354         return ret_arr;
52355 }
52356
52357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
52358         LDKRawInvoice this_arg_conv;
52359         this_arg_conv.inner = untag_ptr(this_arg);
52360         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52362         this_arg_conv.is_owned = false;
52363         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
52364         int64_t ret_ref = 0;
52365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52367         return ret_ref;
52368 }
52369
52370 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
52371         LDKRawInvoice this_arg_conv;
52372         this_arg_conv.inner = untag_ptr(this_arg);
52373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52375         this_arg_conv.is_owned = false;
52376         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
52377         int64_tArray ret_arr = NULL;
52378         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52379         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52380         for (size_t o = 0; o < ret_var.datalen; o++) {
52381                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
52382                 int64_t ret_conv_14_ref = 0;
52383                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52384                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52385                 ret_arr_ptr[o] = ret_conv_14_ref;
52386         }
52387         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52388         FREE(ret_var.data);
52389         return ret_arr;
52390 }
52391
52392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
52393         LDKRawInvoice this_arg_conv;
52394         this_arg_conv.inner = untag_ptr(this_arg);
52395         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52397         this_arg_conv.is_owned = false;
52398         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52399         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
52400         int64_t ret_ref = tag_ptr(ret_copy, true);
52401         return ret_ref;
52402 }
52403
52404 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
52405         LDKRawInvoice this_arg_conv;
52406         this_arg_conv.inner = untag_ptr(this_arg);
52407         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52409         this_arg_conv.is_owned = false;
52410         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
52411         return ret_conv;
52412 }
52413
52414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
52415         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
52416         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
52417         return tag_ptr(ret_conv, true);
52418 }
52419
52420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
52421         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
52422         *ret_conv = PositiveTimestamp_from_system_time(time);
52423         return tag_ptr(ret_conv, true);
52424 }
52425
52426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
52427         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
52428         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
52429         return tag_ptr(ret_conv, true);
52430 }
52431
52432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
52433         LDKPositiveTimestamp this_arg_conv;
52434         this_arg_conv.inner = untag_ptr(this_arg);
52435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52437         this_arg_conv.is_owned = false;
52438         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
52439         return ret_conv;
52440 }
52441
52442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
52443         LDKPositiveTimestamp this_arg_conv;
52444         this_arg_conv.inner = untag_ptr(this_arg);
52445         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52447         this_arg_conv.is_owned = false;
52448         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
52449         return ret_conv;
52450 }
52451
52452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
52453         LDKPositiveTimestamp this_arg_conv;
52454         this_arg_conv.inner = untag_ptr(this_arg);
52455         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52457         this_arg_conv.is_owned = false;
52458         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
52459         return ret_conv;
52460 }
52461
52462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
52463         LDKInvoice this_arg_conv;
52464         this_arg_conv.inner = untag_ptr(this_arg);
52465         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52467         this_arg_conv = Invoice_clone(&this_arg_conv);
52468         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
52469         int64_t ret_ref = 0;
52470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52472         return ret_ref;
52473 }
52474
52475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
52476         LDKInvoice this_arg_conv;
52477         this_arg_conv.inner = untag_ptr(this_arg);
52478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52480         this_arg_conv.is_owned = false;
52481         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
52482         *ret_conv = Invoice_check_signature(&this_arg_conv);
52483         return tag_ptr(ret_conv, true);
52484 }
52485
52486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
52487         LDKSignedRawInvoice signed_invoice_conv;
52488         signed_invoice_conv.inner = untag_ptr(signed_invoice);
52489         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
52490         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
52491         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
52492         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
52493         *ret_conv = Invoice_from_signed(signed_invoice_conv);
52494         return tag_ptr(ret_conv, true);
52495 }
52496
52497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
52498         LDKInvoice this_arg_conv;
52499         this_arg_conv.inner = untag_ptr(this_arg);
52500         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52502         this_arg_conv.is_owned = false;
52503         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
52504         return ret_conv;
52505 }
52506
52507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
52508         LDKInvoice this_arg_conv;
52509         this_arg_conv.inner = untag_ptr(this_arg);
52510         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52512         this_arg_conv.is_owned = false;
52513         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
52514         return ret_conv;
52515 }
52516
52517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52518         LDKInvoice this_arg_conv;
52519         this_arg_conv.inner = untag_ptr(this_arg);
52520         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52522         this_arg_conv.is_owned = false;
52523         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
52525         return ret_arr;
52526 }
52527
52528 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52529         LDKInvoice this_arg_conv;
52530         this_arg_conv.inner = untag_ptr(this_arg);
52531         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52533         this_arg_conv.is_owned = false;
52534         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52535         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
52536         return ret_arr;
52537 }
52538
52539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
52540         LDKInvoice this_arg_conv;
52541         this_arg_conv.inner = untag_ptr(this_arg);
52542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52544         this_arg_conv.is_owned = false;
52545         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
52547         return ret_arr;
52548 }
52549
52550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
52551         LDKInvoice this_arg_conv;
52552         this_arg_conv.inner = untag_ptr(this_arg);
52553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52555         this_arg_conv.is_owned = false;
52556         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
52557         int64_t ret_ref = 0;
52558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52560         return ret_ref;
52561 }
52562
52563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52564         LDKInvoice this_arg_conv;
52565         this_arg_conv.inner = untag_ptr(this_arg);
52566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52568         this_arg_conv.is_owned = false;
52569         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
52571         return ret_arr;
52572 }
52573
52574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
52575         LDKInvoice this_arg_conv;
52576         this_arg_conv.inner = untag_ptr(this_arg);
52577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52579         this_arg_conv.is_owned = false;
52580         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
52581         return ret_conv;
52582 }
52583
52584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
52585         LDKInvoice this_arg_conv;
52586         this_arg_conv.inner = untag_ptr(this_arg);
52587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52589         this_arg_conv.is_owned = false;
52590         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
52591         return ret_conv;
52592 }
52593
52594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
52595         LDKInvoice this_arg_conv;
52596         this_arg_conv.inner = untag_ptr(this_arg);
52597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52599         this_arg_conv.is_owned = false;
52600         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
52601         return ret_conv;
52602 }
52603
52604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
52605         LDKInvoice this_arg_conv;
52606         this_arg_conv.inner = untag_ptr(this_arg);
52607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52609         this_arg_conv.is_owned = false;
52610         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
52611         return ret_conv;
52612 }
52613
52614 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
52615         LDKInvoice this_arg_conv;
52616         this_arg_conv.inner = untag_ptr(this_arg);
52617         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52619         this_arg_conv.is_owned = false;
52620         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
52621         int64_tArray ret_arr = NULL;
52622         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52623         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52624         for (size_t o = 0; o < ret_var.datalen; o++) {
52625                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
52626                 int64_t ret_conv_14_ref = 0;
52627                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52628                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52629                 ret_arr_ptr[o] = ret_conv_14_ref;
52630         }
52631         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52632         FREE(ret_var.data);
52633         return ret_arr;
52634 }
52635
52636 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
52637         LDKInvoice this_arg_conv;
52638         this_arg_conv.inner = untag_ptr(this_arg);
52639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52641         this_arg_conv.is_owned = false;
52642         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
52643         int64_tArray ret_arr = NULL;
52644         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52645         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52646         for (size_t l = 0; l < ret_var.datalen; l++) {
52647                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
52648                 int64_t ret_conv_11_ref = 0;
52649                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
52650                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
52651                 ret_arr_ptr[l] = ret_conv_11_ref;
52652         }
52653         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52654         FREE(ret_var.data);
52655         return ret_arr;
52656 }
52657
52658 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
52659         LDKInvoice this_arg_conv;
52660         this_arg_conv.inner = untag_ptr(this_arg);
52661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52663         this_arg_conv.is_owned = false;
52664         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
52665         return ret_conv;
52666 }
52667
52668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
52669         LDKInvoice this_arg_conv;
52670         this_arg_conv.inner = untag_ptr(this_arg);
52671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52673         this_arg_conv.is_owned = false;
52674         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52675         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
52676         int64_t ret_ref = tag_ptr(ret_copy, true);
52677         return ret_ref;
52678 }
52679
52680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
52681         LDKStr description_conv = java_to_owned_str(env, description);
52682         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
52683         *ret_conv = Description_new(description_conv);
52684         return tag_ptr(ret_conv, true);
52685 }
52686
52687 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
52688         LDKDescription this_arg_conv;
52689         this_arg_conv.inner = untag_ptr(this_arg);
52690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52692         this_arg_conv = Description_clone(&this_arg_conv);
52693         LDKStr ret_str = Description_into_inner(this_arg_conv);
52694         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52695         Str_free(ret_str);
52696         return ret_conv;
52697 }
52698
52699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
52700         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
52701         int64_t ret_ref = 0;
52702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52704         return ret_ref;
52705 }
52706
52707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
52708         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
52709         int64_t ret_ref = 0;
52710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52711         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52712         return ret_ref;
52713 }
52714
52715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
52716         LDKExpiryTime this_arg_conv;
52717         this_arg_conv.inner = untag_ptr(this_arg);
52718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52720         this_arg_conv.is_owned = false;
52721         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
52722         return ret_conv;
52723 }
52724
52725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
52726         LDKExpiryTime this_arg_conv;
52727         this_arg_conv.inner = untag_ptr(this_arg);
52728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52730         this_arg_conv.is_owned = false;
52731         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
52732         return ret_conv;
52733 }
52734
52735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
52736         LDKRouteHint hops_conv;
52737         hops_conv.inner = untag_ptr(hops);
52738         hops_conv.is_owned = ptr_is_owned(hops);
52739         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
52740         hops_conv = RouteHint_clone(&hops_conv);
52741         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
52742         *ret_conv = PrivateRoute_new(hops_conv);
52743         return tag_ptr(ret_conv, true);
52744 }
52745
52746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
52747         LDKPrivateRoute this_arg_conv;
52748         this_arg_conv.inner = untag_ptr(this_arg);
52749         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52751         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
52752         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
52753         int64_t ret_ref = 0;
52754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52756         return ret_ref;
52757 }
52758
52759 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52760         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
52761         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
52762         return ret_conv;
52763 }
52764
52765 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
52766         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
52767         return ret_conv;
52768 }
52769
52770 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
52771         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
52772         return ret_conv;
52773 }
52774
52775 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
52776         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
52777         return ret_conv;
52778 }
52779
52780 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
52781         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
52782         return ret_conv;
52783 }
52784
52785 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
52786         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
52787         return ret_conv;
52788 }
52789
52790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52791         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
52792         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
52793         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
52794         return ret_conv;
52795 }
52796
52797 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
52798         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
52799         LDKStr ret_str = CreationError_to_str(o_conv);
52800         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52801         Str_free(ret_str);
52802         return ret_conv;
52803 }
52804
52805 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52806         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
52807         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
52808         return ret_conv;
52809 }
52810
52811 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
52812         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
52813         return ret_conv;
52814 }
52815
52816 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
52817         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
52818         return ret_conv;
52819 }
52820
52821 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
52822         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
52823         return ret_conv;
52824 }
52825
52826 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
52827         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
52828         return ret_conv;
52829 }
52830
52831 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
52832         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
52833         return ret_conv;
52834 }
52835
52836 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
52837         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
52838         return ret_conv;
52839 }
52840
52841 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
52842         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
52843         return ret_conv;
52844 }
52845
52846 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
52847         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
52848         return ret_conv;
52849 }
52850
52851 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
52852         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
52853         return ret_conv;
52854 }
52855
52856 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
52857         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
52858         return ret_conv;
52859 }
52860
52861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52862         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
52863         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
52864         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
52865         return ret_conv;
52866 }
52867
52868 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
52869         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
52870         LDKStr ret_str = SemanticError_to_str(o_conv);
52871         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52872         Str_free(ret_str);
52873         return ret_conv;
52874 }
52875
52876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52877         if (!ptr_is_owned(this_ptr)) return;
52878         void* this_ptr_ptr = untag_ptr(this_ptr);
52879         CHECK_ACCESS(this_ptr_ptr);
52880         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
52881         FREE(untag_ptr(this_ptr));
52882         SignOrCreationError_free(this_ptr_conv);
52883 }
52884
52885 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
52886         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52887         *ret_copy = SignOrCreationError_clone(arg);
52888         int64_t ret_ref = tag_ptr(ret_copy, true);
52889         return ret_ref;
52890 }
52891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52892         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
52893         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
52894         return ret_conv;
52895 }
52896
52897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52898         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
52899         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52900         *ret_copy = SignOrCreationError_clone(orig_conv);
52901         int64_t ret_ref = tag_ptr(ret_copy, true);
52902         return ret_ref;
52903 }
52904
52905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
52906         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52907         *ret_copy = SignOrCreationError_sign_error();
52908         int64_t ret_ref = tag_ptr(ret_copy, true);
52909         return ret_ref;
52910 }
52911
52912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
52913         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
52914         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52915         *ret_copy = SignOrCreationError_creation_error(a_conv);
52916         int64_t ret_ref = tag_ptr(ret_copy, true);
52917         return ret_ref;
52918 }
52919
52920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52921         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
52922         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
52923         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
52924         return ret_conv;
52925 }
52926
52927 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
52928         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
52929         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
52930         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52931         Str_free(ret_str);
52932         return ret_conv;
52933 }
52934
52935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52936         LDKInvoicePayer this_obj_conv;
52937         this_obj_conv.inner = untag_ptr(this_obj);
52938         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52940         InvoicePayer_free(this_obj_conv);
52941 }
52942
52943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52944         if (!ptr_is_owned(this_ptr)) return;
52945         void* this_ptr_ptr = untag_ptr(this_ptr);
52946         CHECK_ACCESS(this_ptr_ptr);
52947         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
52948         FREE(untag_ptr(this_ptr));
52949         Payer_free(this_ptr_conv);
52950 }
52951
52952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52953         if (!ptr_is_owned(this_ptr)) return;
52954         void* this_ptr_ptr = untag_ptr(this_ptr);
52955         CHECK_ACCESS(this_ptr_ptr);
52956         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
52957         FREE(untag_ptr(this_ptr));
52958         Retry_free(this_ptr_conv);
52959 }
52960
52961 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
52962         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52963         *ret_copy = Retry_clone(arg);
52964         int64_t ret_ref = tag_ptr(ret_copy, true);
52965         return ret_ref;
52966 }
52967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52968         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
52969         int64_t ret_conv = Retry_clone_ptr(arg_conv);
52970         return ret_conv;
52971 }
52972
52973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52974         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
52975         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52976         *ret_copy = Retry_clone(orig_conv);
52977         int64_t ret_ref = tag_ptr(ret_copy, true);
52978         return ret_ref;
52979 }
52980
52981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
52982         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52983         *ret_copy = Retry_attempts(a);
52984         int64_t ret_ref = tag_ptr(ret_copy, true);
52985         return ret_ref;
52986 }
52987
52988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
52989         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52990         *ret_copy = Retry_timeout(a);
52991         int64_t ret_ref = tag_ptr(ret_copy, true);
52992         return ret_ref;
52993 }
52994
52995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52996         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
52997         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
52998         jboolean ret_conv = Retry_eq(a_conv, b_conv);
52999         return ret_conv;
53000 }
53001
53002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
53003         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
53004         int64_t ret_conv = Retry_hash(o_conv);
53005         return ret_conv;
53006 }
53007
53008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53009         if (!ptr_is_owned(this_ptr)) return;
53010         void* this_ptr_ptr = untag_ptr(this_ptr);
53011         CHECK_ACCESS(this_ptr_ptr);
53012         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
53013         FREE(untag_ptr(this_ptr));
53014         PaymentError_free(this_ptr_conv);
53015 }
53016
53017 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
53018         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53019         *ret_copy = PaymentError_clone(arg);
53020         int64_t ret_ref = tag_ptr(ret_copy, true);
53021         return ret_ref;
53022 }
53023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53024         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
53025         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
53026         return ret_conv;
53027 }
53028
53029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53030         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
53031         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53032         *ret_copy = PaymentError_clone(orig_conv);
53033         int64_t ret_ref = tag_ptr(ret_copy, true);
53034         return ret_ref;
53035 }
53036
53037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
53038         LDKStr a_conv = java_to_owned_str(env, a);
53039         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53040         *ret_copy = PaymentError_invoice(a_conv);
53041         int64_t ret_ref = tag_ptr(ret_copy, true);
53042         return ret_ref;
53043 }
53044
53045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
53046         LDKLightningError a_conv;
53047         a_conv.inner = untag_ptr(a);
53048         a_conv.is_owned = ptr_is_owned(a);
53049         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53050         a_conv = LightningError_clone(&a_conv);
53051         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53052         *ret_copy = PaymentError_routing(a_conv);
53053         int64_t ret_ref = tag_ptr(ret_copy, true);
53054         return ret_ref;
53055 }
53056
53057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
53058         void* a_ptr = untag_ptr(a);
53059         CHECK_ACCESS(a_ptr);
53060         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
53061         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
53062         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53063         *ret_copy = PaymentError_sending(a_conv);
53064         int64_t ret_ref = tag_ptr(ret_copy, true);
53065         return ret_ref;
53066 }
53067
53068 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) {
53069         void* payer_ptr = untag_ptr(payer);
53070         CHECK_ACCESS(payer_ptr);
53071         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
53072         if (payer_conv.free == LDKPayer_JCalls_free) {
53073                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53074                 LDKPayer_JCalls_cloned(&payer_conv);
53075         }
53076         void* router_ptr = untag_ptr(router);
53077         CHECK_ACCESS(router_ptr);
53078         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
53079         if (router_conv.free == LDKRouter_JCalls_free) {
53080                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53081                 LDKRouter_JCalls_cloned(&router_conv);
53082         }
53083         void* logger_ptr = untag_ptr(logger);
53084         CHECK_ACCESS(logger_ptr);
53085         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53086         if (logger_conv.free == LDKLogger_JCalls_free) {
53087                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53088                 LDKLogger_JCalls_cloned(&logger_conv);
53089         }
53090         void* event_handler_ptr = untag_ptr(event_handler);
53091         CHECK_ACCESS(event_handler_ptr);
53092         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
53093         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
53094                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53095                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
53096         }
53097         void* retry_ptr = untag_ptr(retry);
53098         CHECK_ACCESS(retry_ptr);
53099         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
53100         retry_conv = Retry_clone((LDKRetry*)untag_ptr(retry));
53101         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, logger_conv, event_handler_conv, retry_conv);
53102         int64_t ret_ref = 0;
53103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53104         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53105         return ret_ref;
53106 }
53107
53108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
53109         LDKInvoicePayer this_arg_conv;
53110         this_arg_conv.inner = untag_ptr(this_arg);
53111         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53113         this_arg_conv.is_owned = false;
53114         LDKInvoice invoice_conv;
53115         invoice_conv.inner = untag_ptr(invoice);
53116         invoice_conv.is_owned = ptr_is_owned(invoice);
53117         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53118         invoice_conv.is_owned = false;
53119         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
53120         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
53121         return tag_ptr(ret_conv, true);
53122 }
53123
53124 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) {
53125         LDKInvoicePayer this_arg_conv;
53126         this_arg_conv.inner = untag_ptr(this_arg);
53127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53129         this_arg_conv.is_owned = false;
53130         LDKInvoice invoice_conv;
53131         invoice_conv.inner = untag_ptr(invoice);
53132         invoice_conv.is_owned = ptr_is_owned(invoice);
53133         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53134         invoice_conv.is_owned = false;
53135         LDKThirtyTwoBytes payment_id_ref;
53136         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
53137         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
53138         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
53139         *ret_conv = InvoicePayer_pay_invoice_with_id(&this_arg_conv, &invoice_conv, payment_id_ref);
53140         return tag_ptr(ret_conv, true);
53141 }
53142
53143 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) {
53144         LDKInvoicePayer this_arg_conv;
53145         this_arg_conv.inner = untag_ptr(this_arg);
53146         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53148         this_arg_conv.is_owned = false;
53149         LDKInvoice invoice_conv;
53150         invoice_conv.inner = untag_ptr(invoice);
53151         invoice_conv.is_owned = ptr_is_owned(invoice);
53152         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53153         invoice_conv.is_owned = false;
53154         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
53155         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
53156         return tag_ptr(ret_conv, true);
53157 }
53158
53159 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) {
53160         LDKInvoicePayer this_arg_conv;
53161         this_arg_conv.inner = untag_ptr(this_arg);
53162         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53164         this_arg_conv.is_owned = false;
53165         LDKInvoice invoice_conv;
53166         invoice_conv.inner = untag_ptr(invoice);
53167         invoice_conv.is_owned = ptr_is_owned(invoice);
53168         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53169         invoice_conv.is_owned = false;
53170         LDKThirtyTwoBytes payment_id_ref;
53171         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
53172         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
53173         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
53174         *ret_conv = InvoicePayer_pay_zero_value_invoice_with_id(&this_arg_conv, &invoice_conv, amount_msats, payment_id_ref);
53175         return tag_ptr(ret_conv, true);
53176 }
53177
53178 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) {
53179         LDKInvoicePayer this_arg_conv;
53180         this_arg_conv.inner = untag_ptr(this_arg);
53181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53183         this_arg_conv.is_owned = false;
53184         LDKPublicKey pubkey_ref;
53185         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
53186         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
53187         LDKThirtyTwoBytes payment_preimage_ref;
53188         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53189         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53190         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
53191         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
53192         return tag_ptr(ret_conv, true);
53193 }
53194
53195 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) {
53196         LDKInvoicePayer this_arg_conv;
53197         this_arg_conv.inner = untag_ptr(this_arg);
53198         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53200         this_arg_conv.is_owned = false;
53201         LDKPublicKey pubkey_ref;
53202         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
53203         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
53204         LDKThirtyTwoBytes payment_preimage_ref;
53205         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53206         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53207         LDKThirtyTwoBytes payment_id_ref;
53208         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
53209         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
53210         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
53211         *ret_conv = InvoicePayer_pay_pubkey_with_id(&this_arg_conv, pubkey_ref, payment_preimage_ref, payment_id_ref, amount_msats, final_cltv_expiry_delta);
53212         return tag_ptr(ret_conv, true);
53213 }
53214
53215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
53216         LDKInvoicePayer this_arg_conv;
53217         this_arg_conv.inner = untag_ptr(this_arg);
53218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53220         this_arg_conv.is_owned = false;
53221         unsigned char payment_hash_arr[32];
53222         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53223         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
53224         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
53225         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
53226 }
53227
53228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
53229         LDKInvoicePayer this_arg_conv;
53230         this_arg_conv.inner = untag_ptr(this_arg);
53231         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53233         this_arg_conv.is_owned = false;
53234         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
53235         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
53236         return tag_ptr(ret_ret, true);
53237 }
53238
53239 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) {
53240         void* amt_msat_ptr = untag_ptr(amt_msat);
53241         CHECK_ACCESS(amt_msat_ptr);
53242         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53243         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53244         LDKThirtyTwoBytes payment_hash_ref;
53245         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53246         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
53247         LDKStr description_conv = java_to_owned_str(env, description);
53248         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
53249         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
53250         if (phantom_route_hints_constr.datalen > 0)
53251                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
53252         else
53253                 phantom_route_hints_constr.data = NULL;
53254         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
53255         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
53256                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
53257                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
53258                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
53259                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
53260                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
53261                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
53262                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
53263         }
53264         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
53265         void* keys_manager_ptr = untag_ptr(keys_manager);
53266         CHECK_ACCESS(keys_manager_ptr);
53267         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53268         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53269                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53270                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53271         }
53272         void* logger_ptr = untag_ptr(logger);
53273         CHECK_ACCESS(logger_ptr);
53274         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53275         if (logger_conv.free == LDKLogger_JCalls_free) {
53276                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53277                 LDKLogger_JCalls_cloned(&logger_conv);
53278         }
53279         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53280         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53281         *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);
53282         return tag_ptr(ret_conv, true);
53283 }
53284
53285 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) {
53286         void* amt_msat_ptr = untag_ptr(amt_msat);
53287         CHECK_ACCESS(amt_msat_ptr);
53288         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53289         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53290         LDKThirtyTwoBytes payment_hash_ref;
53291         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53292         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
53293         LDKSha256 description_hash_conv;
53294         description_hash_conv.inner = untag_ptr(description_hash);
53295         description_hash_conv.is_owned = ptr_is_owned(description_hash);
53296         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
53297         description_hash_conv = Sha256_clone(&description_hash_conv);
53298         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
53299         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
53300         if (phantom_route_hints_constr.datalen > 0)
53301                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
53302         else
53303                 phantom_route_hints_constr.data = NULL;
53304         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
53305         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
53306                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
53307                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
53308                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
53309                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
53310                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
53311                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
53312                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
53313         }
53314         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
53315         void* keys_manager_ptr = untag_ptr(keys_manager);
53316         CHECK_ACCESS(keys_manager_ptr);
53317         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53318         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53319                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53320                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53321         }
53322         void* logger_ptr = untag_ptr(logger);
53323         CHECK_ACCESS(logger_ptr);
53324         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53325         if (logger_conv.free == LDKLogger_JCalls_free) {
53326                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53327                 LDKLogger_JCalls_cloned(&logger_conv);
53328         }
53329         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53330         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53331         *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);
53332         return tag_ptr(ret_conv, true);
53333 }
53334
53335 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) {
53336         LDKChannelManager channelmanager_conv;
53337         channelmanager_conv.inner = untag_ptr(channelmanager);
53338         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53339         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53340         channelmanager_conv.is_owned = false;
53341         void* keys_manager_ptr = untag_ptr(keys_manager);
53342         CHECK_ACCESS(keys_manager_ptr);
53343         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53344         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53345                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53346                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53347         }
53348         void* logger_ptr = untag_ptr(logger);
53349         CHECK_ACCESS(logger_ptr);
53350         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53351         if (logger_conv.free == LDKLogger_JCalls_free) {
53352                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53353                 LDKLogger_JCalls_cloned(&logger_conv);
53354         }
53355         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53356         void* amt_msat_ptr = untag_ptr(amt_msat);
53357         CHECK_ACCESS(amt_msat_ptr);
53358         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53359         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53360         LDKStr description_conv = java_to_owned_str(env, description);
53361         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53362         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
53363         return tag_ptr(ret_conv, true);
53364 }
53365
53366 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) {
53367         LDKChannelManager channelmanager_conv;
53368         channelmanager_conv.inner = untag_ptr(channelmanager);
53369         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53370         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53371         channelmanager_conv.is_owned = false;
53372         void* keys_manager_ptr = untag_ptr(keys_manager);
53373         CHECK_ACCESS(keys_manager_ptr);
53374         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53375         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53376                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53377                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53378         }
53379         void* logger_ptr = untag_ptr(logger);
53380         CHECK_ACCESS(logger_ptr);
53381         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53382         if (logger_conv.free == LDKLogger_JCalls_free) {
53383                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53384                 LDKLogger_JCalls_cloned(&logger_conv);
53385         }
53386         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53387         void* amt_msat_ptr = untag_ptr(amt_msat);
53388         CHECK_ACCESS(amt_msat_ptr);
53389         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53390         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53391         LDKSha256 description_hash_conv;
53392         description_hash_conv.inner = untag_ptr(description_hash);
53393         description_hash_conv.is_owned = ptr_is_owned(description_hash);
53394         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
53395         description_hash_conv = Sha256_clone(&description_hash_conv);
53396         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53397         *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);
53398         return tag_ptr(ret_conv, true);
53399 }
53400
53401 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) {
53402         LDKChannelManager channelmanager_conv;
53403         channelmanager_conv.inner = untag_ptr(channelmanager);
53404         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53405         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53406         channelmanager_conv.is_owned = false;
53407         void* keys_manager_ptr = untag_ptr(keys_manager);
53408         CHECK_ACCESS(keys_manager_ptr);
53409         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53410         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53411                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53412                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53413         }
53414         void* logger_ptr = untag_ptr(logger);
53415         CHECK_ACCESS(logger_ptr);
53416         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53417         if (logger_conv.free == LDKLogger_JCalls_free) {
53418                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53419                 LDKLogger_JCalls_cloned(&logger_conv);
53420         }
53421         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53422         void* amt_msat_ptr = untag_ptr(amt_msat);
53423         CHECK_ACCESS(amt_msat_ptr);
53424         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53425         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53426         LDKSha256 description_hash_conv;
53427         description_hash_conv.inner = untag_ptr(description_hash);
53428         description_hash_conv.is_owned = ptr_is_owned(description_hash);
53429         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
53430         description_hash_conv = Sha256_clone(&description_hash_conv);
53431         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53432         *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);
53433         return tag_ptr(ret_conv, true);
53434 }
53435
53436 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) {
53437         LDKChannelManager channelmanager_conv;
53438         channelmanager_conv.inner = untag_ptr(channelmanager);
53439         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53440         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53441         channelmanager_conv.is_owned = false;
53442         void* keys_manager_ptr = untag_ptr(keys_manager);
53443         CHECK_ACCESS(keys_manager_ptr);
53444         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53445         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53446                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53447                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53448         }
53449         void* logger_ptr = untag_ptr(logger);
53450         CHECK_ACCESS(logger_ptr);
53451         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53452         if (logger_conv.free == LDKLogger_JCalls_free) {
53453                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53454                 LDKLogger_JCalls_cloned(&logger_conv);
53455         }
53456         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53457         void* amt_msat_ptr = untag_ptr(amt_msat);
53458         CHECK_ACCESS(amt_msat_ptr);
53459         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53460         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53461         LDKStr description_conv = java_to_owned_str(env, description);
53462         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53463         *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);
53464         return tag_ptr(ret_conv, true);
53465 }
53466
53467 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) {
53468         LDKChannelManager channelmanager_conv;
53469         channelmanager_conv.inner = untag_ptr(channelmanager);
53470         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53471         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53472         channelmanager_conv.is_owned = false;
53473         void* keys_manager_ptr = untag_ptr(keys_manager);
53474         CHECK_ACCESS(keys_manager_ptr);
53475         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53476         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53477                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53478                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53479         }
53480         void* logger_ptr = untag_ptr(logger);
53481         CHECK_ACCESS(logger_ptr);
53482         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53483         if (logger_conv.free == LDKLogger_JCalls_free) {
53484                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53485                 LDKLogger_JCalls_cloned(&logger_conv);
53486         }
53487         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53488         void* amt_msat_ptr = untag_ptr(amt_msat);
53489         CHECK_ACCESS(amt_msat_ptr);
53490         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53491         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53492         LDKStr description_conv = java_to_owned_str(env, description);
53493         LDKThirtyTwoBytes payment_hash_ref;
53494         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53495         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
53496         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53497         *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);
53498         return tag_ptr(ret_conv, true);
53499 }
53500
53501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
53502         LDKChannelManager this_arg_conv;
53503         this_arg_conv.inner = untag_ptr(this_arg);
53504         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53506         this_arg_conv.is_owned = false;
53507         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
53508         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
53509         return tag_ptr(ret_ret, true);
53510 }
53511
53512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
53513         LDKStr s_conv = java_to_owned_str(env, s);
53514         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
53515         *ret_conv = SiPrefix_from_str(s_conv);
53516         return tag_ptr(ret_conv, true);
53517 }
53518
53519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
53520         LDKStr s_conv = java_to_owned_str(env, s);
53521         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
53522         *ret_conv = Invoice_from_str(s_conv);
53523         return tag_ptr(ret_conv, true);
53524 }
53525
53526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
53527         LDKStr s_conv = java_to_owned_str(env, s);
53528         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
53529         *ret_conv = SignedRawInvoice_from_str(s_conv);
53530         return tag_ptr(ret_conv, true);
53531 }
53532
53533 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53534         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
53535         LDKStr ret_str = ParseError_to_str(o_conv);
53536         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53537         Str_free(ret_str);
53538         return ret_conv;
53539 }
53540
53541 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53542         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
53543         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
53544         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53545         Str_free(ret_str);
53546         return ret_conv;
53547 }
53548
53549 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53550         LDKInvoice o_conv;
53551         o_conv.inner = untag_ptr(o);
53552         o_conv.is_owned = ptr_is_owned(o);
53553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53554         o_conv.is_owned = false;
53555         LDKStr ret_str = Invoice_to_str(&o_conv);
53556         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53557         Str_free(ret_str);
53558         return ret_conv;
53559 }
53560
53561 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53562         LDKSignedRawInvoice o_conv;
53563         o_conv.inner = untag_ptr(o);
53564         o_conv.is_owned = ptr_is_owned(o);
53565         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53566         o_conv.is_owned = false;
53567         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
53568         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53569         Str_free(ret_str);
53570         return ret_conv;
53571 }
53572
53573 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53574         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
53575         LDKStr ret_str = Currency_to_str(o_conv);
53576         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53577         Str_free(ret_str);
53578         return ret_conv;
53579 }
53580
53581 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53582         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
53583         LDKStr ret_str = SiPrefix_to_str(o_conv);
53584         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53585         Str_free(ret_str);
53586         return ret_conv;
53587 }
53588
53589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53590         LDKRapidGossipSync this_obj_conv;
53591         this_obj_conv.inner = untag_ptr(this_obj);
53592         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53594         RapidGossipSync_free(this_obj_conv);
53595 }
53596
53597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
53598         LDKNetworkGraph network_graph_conv;
53599         network_graph_conv.inner = untag_ptr(network_graph);
53600         network_graph_conv.is_owned = ptr_is_owned(network_graph);
53601         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
53602         network_graph_conv.is_owned = false;
53603         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
53604         int64_t ret_ref = 0;
53605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53606         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53607         return ret_ref;
53608 }
53609
53610 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) {
53611         LDKRapidGossipSync this_arg_conv;
53612         this_arg_conv.inner = untag_ptr(this_arg);
53613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53615         this_arg_conv.is_owned = false;
53616         LDKu8slice update_data_ref;
53617         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
53618         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
53619         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
53620         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
53621         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
53622         return tag_ptr(ret_conv, true);
53623 }
53624
53625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
53626         LDKRapidGossipSync this_arg_conv;
53627         this_arg_conv.inner = untag_ptr(this_arg);
53628         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53630         this_arg_conv.is_owned = false;
53631         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
53632         return ret_conv;
53633 }
53634
53635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53636         if (!ptr_is_owned(this_ptr)) return;
53637         void* this_ptr_ptr = untag_ptr(this_ptr);
53638         CHECK_ACCESS(this_ptr_ptr);
53639         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
53640         FREE(untag_ptr(this_ptr));
53641         GraphSyncError_free(this_ptr_conv);
53642 }
53643
53644 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
53645         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53646         *ret_copy = GraphSyncError_clone(arg);
53647         int64_t ret_ref = tag_ptr(ret_copy, true);
53648         return ret_ref;
53649 }
53650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53651         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
53652         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
53653         return ret_conv;
53654 }
53655
53656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53657         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
53658         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53659         *ret_copy = GraphSyncError_clone(orig_conv);
53660         int64_t ret_ref = tag_ptr(ret_copy, true);
53661         return ret_ref;
53662 }
53663
53664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
53665         void* a_ptr = untag_ptr(a);
53666         CHECK_ACCESS(a_ptr);
53667         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
53668         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
53669         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53670         *ret_copy = GraphSyncError_decode_error(a_conv);
53671         int64_t ret_ref = tag_ptr(ret_copy, true);
53672         return ret_ref;
53673 }
53674
53675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
53676         LDKLightningError a_conv;
53677         a_conv.inner = untag_ptr(a);
53678         a_conv.is_owned = ptr_is_owned(a);
53679         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53680         a_conv = LightningError_clone(&a_conv);
53681         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53682         *ret_copy = GraphSyncError_lightning_error(a_conv);
53683         int64_t ret_ref = tag_ptr(ret_copy, true);
53684         return ret_ref;
53685 }
53686